I have problem with binding to static property.
I want to have Label
with Content
true or false depending on the value of bool variable.
XAML:
<Label Content="{Binding Source={x:Static l:MainWindow.IsTrue}, Mode=OneWay}" />
Code behind:
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;
}
}
It displays False all the time.
I know that in order to implement two way binding I need to specify Path
. But I need one way binding.