Binding to static property
Posted
by
Anthony Brien
on Stack Overflow
See other posts from Stack Overflow
or by Anthony Brien
Published on 2009-06-01T19:20:48Z
Indexed on
2014/08/21
10:20 UTC
Read the original article
Hit count: 305
I'm having a hard time binding a simple static string property to a text box.
Here's the class with the static property:
public class VersionManager
{
private static string filterString;
public static string FilterString
{
get { return filterString; }
set { filterString = value; }
}
}
In my xaml, I just want to bind this static property to a text box:
<TextBox>
<TextBox.Text>
<Binding Source="{x:Static local:VersionManager.FilterString}"/>
</TextBox.Text>
</TextBox>
Everything compiles, but at run time, I get the following exception:
Cannot convert the value in attribute 'Source' to object of type 'System.Windows.Markup.StaticExtension'. Error at object 'System.Windows.Data.Binding' in markup file 'BurnDisk;component/selectversionpagefunction.xaml' Line 57 Position 29.
Any idea what I'm doing wrong?
© Stack Overflow or respective owner