Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

複数のコントロール間でプロパティをバインドする

MyWindow.xaml

SliderのValueをTextBoxのテキストにバインドする。

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow">
    <StackPanel>
        <TextBox Name="textBox" Width="100" Text="{Binding ElementName=slider, Path=Value}"></TextBox>
        <Slider Name="slider" />
    </StackPanel>
</Window>

MyWindow.xaml.cs

using System.Windows;

namespace WpfApplication1 {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }
    }
}

起動時


スライダー移動