我有一個xceed網格(不確定這是否重要),其中一列有一個具有TextBlock的CellContentTemplate。而不是將文本塊寬度自動設置爲文本的大小,我希望它是列的大小。我允許調整大小,所以這使事情變得複雜一點。有沒有一種方法來動態改變TextBlock的寬度,當列被調整大小,在代碼後面?當包含它的列被調整大小時,動態設置Textblock的大小
編輯:CellContentTemplate
<DataTemplate x:Key="CellTemplate.TaskName">
<StackPanel Orientation="Horizontal">
<TextBlock Tag="{Binding Path=DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
<TextBlock Text="{Binding Path=Name}" >
<ui:DragDropBinding.DragSource>
<Binding Mode="TwoWay" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type XceedProviders:DataGridControlWithSelectedItems}}" Path="BindableSelectedItems" PresentationTraceSources.TraceLevel="High"/>
</ui:DragDropBinding.DragSource>
</TextBlock>
</TextBlock>
</StackPanel>
</DataTemplate>
您可以粘貼CellContentTemplate代碼嗎? – kmatyaszek 2012-07-12 16:50:07
添加CellContentTemplate – 2012-07-12 16:53:45
嘗試將StackPanel更改爲網格。 – kmatyaszek 2012-07-12 17:32:43