Architect's Log

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

バインディングのプロパティをクラス修飾で指定する

プロパティだけを指定した場合と動作は同じですが、内部でリフレクションを使用しないので、パフォーマンス面で有利です。

アプリ実行

起動


スライダーを移動


ソースコード

App.xaml
<Application x:Class="HelloWorld.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
</Application>
MainWindow.xaml
<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="100" Width="200">
    <StackPanel>
        <Slider Name="slider" />
        <TextBox Text="{Binding ElementName=slider, Path=(Slider.Value)}" />
    </StackPanel>
</Window>