I have just realized I\'ve been coercing binding/dependency properties and not really fundamentally understanding the concept.
Heres the dependency property:
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:
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.