concatenate strings in rowheader - xaml
我的问题如下:我有一个绑定到我的数据表的数据网格。我希望将
我每个人都有成功,但是结合起来会产生空白
1 2 3 4 5 6 7 8 9 10 11 12 | <DataGrid.RowHeaderTemplate> <DataTemplate> <Button Width="90"> <Button.Content> <MultiBinding StringFormat=" {0} - {1}"> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Index"/> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Category"/> </MultiBinding> </Button.Content> </Button> </DataTemplate> </DataGrid.RowHeaderTemplate |
任何帮助将不胜感激。
我认为您的StringFormat语法错误:请尝试:
1 2 3 4 | <MultiBinding StringFormat="{}{0} - {1}"> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Index"/> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Category"/> </MultiBinding> |
尝试添加
1 2 3 4 5 6 7 8 9 10 11 12 | <Button Width="90"> <Button.Content> <TextBlock> <TextBlock.Text> <MultiBinding StringFormat=" {0} - {1}"> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Index"/> <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGridRow}}" Path="Item.Category"/> </MultiBinding> </TextBlock.Text> </TextBlock> </Button.Content> </Button> |
时适用