ソースコード:
class Cons
{
public Cons()
{
BaseDir = AppDomain.CurrentDomain.BaseDirectory;
SetProperty();
}
private void SetProperty()
{
NowPlaying = "Hello";
}
public string NowPlaying{get; set; }
}
public partial class MainWindow
{
Cons Resources = new Cons()
public MainWindow()
{
txbl.DataContext = Resources;
Resources.NowPlaying = "NoHello";
}
}
テキスト ブロック<Textblock x:Name="txbl" Text="{Binding NowPlaying, Mode=TwoWay}"/>
MainWindow コンストラクターで NowPlaying プロパティを設定すると、プロパティが "NoHello" に変更されましたが、バインディング モード = TwoWay を設定しても、TextBlock テキスト プロパティは引き続き Hello です。
