10
我有一个TextBlock
,我需要自动调整到TreeView
的宽度。 TreeView
和TextBlock
都包含在StackPanel
中。 StackPanel
位于Expander
之内。 TreeView
的宽度应驱动其他对象的宽度,我需要TextBlock
的高度更改为显示全文。我所有的努力导致了TextBlock
的宽度。谢谢!如何将文本块设置为自动调整为TreeView的宽度?
<Expander IsEnabled="True" HorizontalAlignment="Right" Margin="0,8,8,53" x:Name="ExpanderBookMarks" Width="Auto" Foreground="#FF625B5B" ExpandDirection="Down" IsExpanded="True" Header="Bookmarks" Visibility="Hidden">
<StackPanel Name ="StackPanelBookmark" Orientation="Vertical" Width="{wpf:Binding Path=Width, ElementName=trvBookmarks, Mode=Default}">
<TreeView x:Name="trvBookmarks" ItemsSource="{Binding}"
ItemTemplateSelector="{StaticResource BookmarkTemplateSelector}"
Margin="0,0,0,0"
TreeViewItem.Selected="HandleTreeViewItemClick" AllowDrop="True"/>
<TextBlock x:Name="TextBlockBookmarkDiscription" TextWrapping="Wrap" Foreground="AntiqueWhite" Background="Transparent" Width="150">
This is the discription area and needs to be very long because the end user can put 400 charectors in.
</TextBlock>
</StackPanel>
<!--End of Dougs Treeview-->
</Expander>
+1传奇。谢谢。 – ozczecho 2010-02-10 12:39:55