请问如何动态的给自定义的style内包含的控件赋值呢
代码如下,我定义了一个grid样式,需要在后台代码中动态的给其中的控件赋值
应该怎么操作呢,需要动态生成的部分已经标出
有没有什么好的方法吗?我需要重复的使用这个框架,作为消息格式,如果每次都循环查找节点感觉很麻烦
<Style x:Key="CustomTable" TargetType="UserControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="UserControl">
<Grid Name="gFrame">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Name="headerImg" Height="30"></Image>//需要赋值的项
<Grid Name="gInner">
<Grid.RowDefinitions>
<RowDefinition Height="10"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Name="nickName" ></TextBlock>//需要赋值的项
<Grid Name="gContent">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Name="gReal" Grid.Column="1">
//这里需要动态加入一些新的控件
</Grid>
</Grid>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>