2008-12-19 11 views
10

Tengo un TextBlock que necesito autoesificar al ancho de TreeView. El TreeView y el TextBlock están contenidos en un StackPanel. El StackPanel está dentro de un Expander. El ancho del TreeView debe manejar el ancho de los otros objetos y necesito el alto del TextBlock para cambiarlo y mostrar el texto completo. Todos mis esfuerzos han resultado en el TextBlock manejando el ancho. ¡Gracias!¿Cómo se configura un bloque de texto para que se ajuste automáticamente al ancho de un 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> 

Respuesta

18

Prueba esto:

<TextBlock Width="{Binding ElementName=trvBookmarks,Path=ActualWidth}" ... /> 
+0

+1 leyenda. Gracias. – ozczecho

Cuestiones relacionadas