I have data template formatting elements in a ListBox
<DataTemplate x:Key="ChildViewModelTemplate">
<Border BorderBrush="#FFDC1C1C" BorderThickness="1" >
<Grid>
<TextBlock Text="{Binding Path=DisplayName}"></TextBlock>
<Image Height="Auto" Margin="0,0,2,0" VerticalAlignment="Stretch" HorizontalAlignment="Right" Width="31" Source="pack://siteoforigin:,,,/rocket.ico"/>
</Grid>
</Border>
</DataTemplate>
This places a border around each element that extends to the length of the text string associated with the TextBlock binding.
Is there an easy way to have all elements of the same width where the width is equal to the longest element? For bonus points, I wonder if there is a way to do this for the longest visible element and / or the longest element, regardless of whether it is visible.
thank
source
share