DataGrid ColumnHeaderStyle TextBlock Multibinding
本文关键字:Multibinding TextBlock ColumnHeaderStyle DataGrid | 更新日期: 2023-09-27 18:14:06
为了显示包含两个属性的格式化字符串,我尝试为列标题设置样式,但没有成功。
我在这里做错了什么?
<DataGrid.ColumnHeaderStyle>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="Background" Value="#BF000000" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Height" Value="32" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Foreground="#FFFFFEFE" FontWeight="Bold" >
<TextBlock.Text>
<MultiBinding StringFormat="**Identified barcodes: {0} / {1}"**>
<Binding Path="Prop1.Prop2.Count" />
<Binding Path="Prop1.Prop3" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGrid.ColumnHeaderStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Code}" Width="*" />
</DataGrid.Columns>
试试这个…
<MultiBinding StringFormat="**Identified barcodes: {} {0} / {1}"**>
<Binding Path="Prop1.Prop2.Count" />
<Binding Path="Prop1.Prop3" />
</MultiBinding>