How to get the text with in the datatemplate?
Posted
by
rakish
on Stack Overflow
See other posts from Stack Overflow
or by rakish
Published on 2013-10-30T06:45:30Z
Indexed on
2013/10/30
9:54 UTC
Read the original article
Hit count: 181
I have used below code
<DataTemplate x:Key="myTemplate">
<TextBlock Text="Hi"></TextBlock>
</DataTemplate>
in this case i can able to get the textblock text by using below code
DataTemplate myTemplate = this.Resources["myTemplate"] as DataTemplate;
TextBlock rootElement = myTemplate.LoadContent() as TextBlock;
//I can get the text "rootElement.text "
but when i use binding means i cant able to get the text
<DataTemplate x:Key="myTemplate">
<TextBlock Text="{Binding EmployeeName}"></TextBlock>
</DataTemplate>
© Stack Overflow or respective owner