DataGrid ColumnHeaderStyle TextBlock Multibinding

时间:2015-09-22 08:29:09

标签: c# wpf datagrid

我没有成功设置列标题,以显示包含2个属性的格式化字符串。

我在这里做错了什么?

<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>

1 个答案:

答案 0 :(得分:0)

试试这个..

<MultiBinding StringFormat="**Identified barcodes: {} {0} / {1}"**>
                        <Binding Path="Prop1.Prop2.Count" />
                        <Binding Path="Prop1.Prop3" />
</MultiBinding>