Let me show you part of my XAML code :
<ListBox Grid.Row="1" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.IsDeferredScrollingEnabled="True"
HorizontalAlignment="Stretch" ItemsSource="{Binding}" Margin="1,1,0,0"
Name="listBox_Faits" Width="290" VerticalAlignment="Stretch"
SelectionChanged="listBox_Faits_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="SlateGray" BorderThickness="0.5" Margin="1,2,1,1"
Width="{Binding ElementName=listBox_Faits, Path=Width}">
When too much borders are created (it is linked with an ObservableCollection), a vertical scroll bar appears, and my border doesn't resize on its own. (I would like to see the complete border, I don t want it to be cut at the end)
If anyone has an idea, thanks! Don't hesitate to ask, if you need more information!
Rgds,
Flo
You can make ListBoxItem stretch by adding this, and then you can remove the Width binding for the Border
<ListBox ...>
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<!-- ... -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With