静的プロパティへのバインドに問題があります。bool変数の値に応じてtrueまたはfalseを
使用したい。Label
Content
XAML:
<Label Content="{Binding Source={x:Static l:MainWindow.IsTrue}, Mode=OneWay}" />
コードビハインド:
public partial class MainWindow : Window
{
public static bool IsTrue { get; set; }
DispatcherTimer myTimer;
public MainWindow()
{
InitializeComponent();
myTimer = new DispatcherTimer();
myTimer.Interval = new TimeSpan(0, 0, 2); // tick every 2 seconds
myTimer.Tick += new EventHandler(myTimer_Tick);
myTimer.IsEnabled = true;
}
void myTimer_Tick(object sender, EventArgs e)
{
IsTrue = !IsTrue;
}
}
常にFalseを表示します。
双方向バインディング を実装するには、指定する必要があることを知っていますPath
。しかし、私は一方向バインディングが必要です。