该守则是:
<GridViewColumn DisplayMemberBinding="{Binding Path=BookId}" Width="100">
<GridViewColumn.Header>
<Border BorderBrush="Black">
<TextBlock Width="{Binding RelativeSource=
{RelativeSource FindAncestor,
AncestorType={x:Type GridViewColumn}},
Path=Width}" Text="ID">
<TextBlock.ContextMenu>
<ContextMenu>item1</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</Border>
</GridViewColumn.Header>
</GridViewColumn>
基本上,我试图做的是使标题中的文字B锁在整栏的宽度之后。
It is not working: the textblock s width always matches the text inside. Any ideas?... Thanks in advance!