Bind a subclass to property
- by Neir0
Hi
i have a simple question. Ofcourse it has many answers but i cannt choose right keywords to google.
How i can bind a subclass to my wpf control?
for example:
It's my class.
public class SiteFieldInfo<T>
{
public string Name { get; set; }
public T Value { get; set; }
public List<string> PositiveXPathExpressions { get; set; }
public List<string> NegativeXPathExpressions { get; set; }
}
public class SiteInfo
{
public SiteFieldInfo<string> Author { get; set; }
public SiteFieldInfo<DateTime> Date { get; set; }
public SiteFieldInfo<string> Source { get; set; }
}
And i want to bind property Value from SiteFieldInfo to Text property of TextBox control.
c# code:
stackPanel1.DataContext = SiteInfoInstance;
xaml code:
<StackPanel Name="stackPanel1">
<TextBlock Text="Author" Grid.Row="0" Grid.Column="0" />
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Author.Value}" />
</StackPanel>
It's not working. What is right syntax or any alternatives?