i have Silverlight Datagrid,i have to make my column header name at runtime ,i successfully bind the column with my class object means binding at runtime , but the problem is that column header name is not showing dynamic text according to my resource file infect the text is not showing at all,anyone help me out to solve this issue in showing the text of column header dynamically,its really urgent, thankz in advance,my code for 1 column is
<data:DataGridTextColumn Header="TuesdayHeader" Binding="{Binding Tuesday, Converter={StaticResource VisibilityConverter}}">
<data:DataGridTextColumn.HeaderStyle>
<Style TargetType="primitives:DataGridColumnHeader">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding TuesdayHeader, Source={StaticResource VisibilityConverter}}"/>
DataTemplate>
Setter.Value>
Setter>
Style>
data:DataGridTextColumn.HeaderStyle>
data:DataGridTextColumn>
Loading
Adeel AnsariPosted Sep 2, 2009, 1:17 AM
Can u please tell me the whole process???
Where should i use this Method that you have given as a solution and what is the heirarchy should follow in the XAML File ?? means i am not still understand the steps to follow that will resolve my issue .
Thankz
Raj GopalPosted Sep 1, 2009, 6:27 AM
You can use this function to find the header text in xaml and dynamically
public TextBlock GetTextBlockWithParent(UIElement parent, Type targetType, string TextBlockName)
{
if (parent.GetType() == targetType && ((TextBlock)parent).Name == TextBlockName)
{
return (TextBlock)parent;
}
TextBlock result = null;
int count = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < count; i++)
{
UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
if (GetTextBlockWithParent(child, targetType, TextBlockName) != null)
{
result = GetTextBlockWithParent(child, targetType, TextBlockName);
break;
}
}
return result;
}