W
Wonko the Sane
Hi All,
Perhaps its because its been a long week, but I just can't seem to figure
out how to bind data in a DataTemplate using DataContext.
The following is in the XAML code:
<Button x:Name="btnRegularDataContext" Margin="5">
<TextBlock Text="{Binding}" />
</Button>
<Button x:Name="btnInDataTemplate" Margin="5">
<Button.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</Button.ContentTemplate>
</Button>
And in the code-behind:
btnRegulareDataContext.DataContext = DateTime.Now.ToShortString();
btnInDataTemplate.DataContext = DateTime.Now.ToShortString();
The first button shows the time, the second does not. What am I missing?!?
Thanks....
Perhaps its because its been a long week, but I just can't seem to figure
out how to bind data in a DataTemplate using DataContext.
The following is in the XAML code:
<Button x:Name="btnRegularDataContext" Margin="5">
<TextBlock Text="{Binding}" />
</Button>
<Button x:Name="btnInDataTemplate" Margin="5">
<Button.ContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</Button.ContentTemplate>
</Button>
And in the code-behind:
btnRegulareDataContext.DataContext = DateTime.Now.ToShortString();
btnInDataTemplate.DataContext = DateTime.Now.ToShortString();
The first button shows the time, the second does not. What am I missing?!?
Thanks....