TreeView의 너비로 자동 크기로 텍스트 블록을 설정하는 방법은 무엇입니까?
문제
나는있다 TextBlock
너비로 자동 크기가 필요합니다. TreeView
. 그만큼 TreeView
그리고 TextBlock
둘 다 a StackPanel
. 그만큼 StackPanel
안에 있습니다 Expander
. 의 너비 TreeView
다른 물체의 너비를 구동해야하며 나는 높이가 필요합니다. TextBlock
전체 텍스트를 표시하도록 변경합니다. 내 모든 노력으로 인해 TextBlock
너비를 운전합니다. 감사!
<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>
해결책
이 시도:
<TextBlock Width="{Binding ElementName=trvBookmarks,Path=ActualWidth}" ... />
제휴하지 않습니다 StackOverflow