Note that there are some explanatory texts on larger screens.

plurals
  1. POwpf border control to span the width of listboxItem
    text
    copied!<p>Im trying to define a dataTemplate for a business object in my wpf application a collection of which is being bound to a ListBox.</p> <pre><code>&lt;UserControl.Resources&gt; &lt;DataTemplate x:Key="ResizedItemsDataTemplate" DataType="{x:Type resizer:ResizeMonitorItem}"&gt; &lt;Border x:Name="bdr" BorderBrush="Blue" BorderThickness="1" CornerRadius="2" Width="auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"&gt; &lt;Grid Margin="2"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="14"&gt;&lt;/RowDefinition&gt; &lt;RowDefinition Height="14"&gt;&lt;/RowDefinition&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Grid.Row="0" Text="{Binding SaveAsFileName}"&gt;&lt;/TextBlock&gt; &lt;TextBlock Grid.Row="1" Text="{Binding ResizedImageFilePath}"&gt;&lt;/TextBlock&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/DataTemplate&gt; &lt;/UserControl.Resources&gt; &lt;Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="0"&gt; &lt;Border BorderThickness="0,0,0,5" BorderBrush="DarkGray" &gt; &lt;ListBox x:Name="ListBoxResizeItems" ItemsSource="{Binding Path=ResizeItems}" BorderThickness="0" ItemTemplate="{DynamicResource ResizedItemsDataTemplate}"&gt; &lt;/ListBox&gt; &lt;/Border&gt; &lt;/Grid&gt; </code></pre> <p>How can I get the border defined with x:Name=bdr to span the full width of each listbox item? At the moment it only spans the with of the textblocks inside it which dont neccessary fill the full width of the listboxitem and also vary for each listboxitem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload