<Window x:Class="WpfTutorialSamples.WPF_Application.ResourceSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Window.Resources>
<sys:String x:Key="centralRes">Hello, world!</sys:String>
</Window.Resources>
<StackPanel Margin="10">
<TextBox Name="src" />
<TextBlock Name="dst" Text="{DynamicResource centralRes}" FontSize="56" />
</StackPanel>
</Window>
私はちょうど学んでいて、string
リテラルcentralRes
を別のコントロールの Text プロパティ (のようなsrc.Text
) にバインドできるかどうか興味があったので、更新すると、それにバインドされているすべてのものはdst
自動的に更新されます。
情報のための中央ハブのようなものです。これは可能ですか?
私が欲しいものの例:
<sys:String x:Key="centralRes" Value="{Binding Text, ElementName=src}">Hello, world!</sys:String>