I have:
<DockPanel>
<!-- Left Panel -->
<LocalViews:MyView1 DockPanel.Dock="Left" Width="250" />
and in MyView1
<DockPanel>
<Button ...
<ListBox>
<ItemsControl.ItemTemplate>
<DataTemplate>
<GroupBox>
<!-- stuff here -->
...
</DataTemplate>
I don't know if that's relevant, but I have completely overridden the default ListItem style, because I want it to look like an ItemTemplate, but with support of SelectedItem:
<Style TargetType="ListBox" x:Key="XXX" BasedOn="{StaticResource {x:Type ListBox}}">
<Style.Resources>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Style.Resources>
</Style>
Vertical scrollbar doesn't show by default (good) and when I resize the window and decrease the available height, it shows up (also good). Problem is, the vertical scrollbar causes a horizontal scrollbar. I don't want that.
What's driving me crazy is that in the Designer (VS) it looks fine:
I have seen solutions where an additional space is left on the side of the inner control, to allow for the scrollbar to appear and another solution where the scrollbar is visible at all times so it doesn't 'jump out'. I don't like either.
My question is - what style do I apply to the listbox item template so that when the vertical scrollbar shows up, the item will resize its width to fit the now shrinked available horizontal space?




