Its a Window this is set in.
public partial class Window1 : Window
{
public string Problem
{
get { return (string)GetValue(ProblemProperty); }
set { SetValue(ProblemProperty, value); }
}
public static readonly DependencyProperty ProblemProperty =
DependencyProperty.Register(
"Problem",
typeof(string),
typeof(Window1));
public Window1()
{
InitializeComponent();
Problem = "ifowiof";
}
public void OnClick(object sender, EventArgs e)
{
Problem = "behl";
}
public void OnCancel(object sender, EventArgs e)
{
Problem = "eioeopje";
}
}
XAML:
<Window x:Class="WpfToolTip.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<Button Click="OnClick" Content="OK" />
<Button Click="OnCancel" Content="Cancel" />
<TextBlock Text="{Binding Path=Problem}" />
</StackPanel>
</Window>
It works if I set the RelativeSource
like you said when it loads, but if i change the Problem
property in code manually (ie. via a button click) it never updates the TextBlock
with the new value.