So I'm having a listbox showing some data in a usercontrol :
<UserControl x:Class="FSBEM.UCs.SomeUC"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Grid Margin="7,0,9,0">
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ListBox x:Name="ListBox"
SelectedValuePath="Id"
ItemsSource="{Binding}"
Margin="0,5,5,5">
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<TextBlock DockPanel.Dock="Right">
<TextBlock.Text>
<MultiBinding StringFormat="{} {0} ">
<Binding Path="Name" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Button x:Name="Btn_Delete"
Padding="5,0,5,0"
CommandParameter="{Binding}">
<Image Source="/Media/Icons/Delete_Icon.png"
Width="10"
Height="10"/>
</Button>
</DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBox Name="txtBox"
Height="22"
Margin="0,14,5,5"/>
</Grid>
</UserControl>
and the problem is that the listbox does not stick to the main window border .. instead it stretches the whole usercontrol down beyond the main window .. I tried setting a MaxHeight but it's not a solution to me. I want to handle it to stick to the main window border and show a scrollbar when there is too mush data to display.
UPDATE this is the xaml code for the MainWindow :
<Window x:Class="FSBEM.MainWindow"
Height="471.997"
Width="1186.374"
WindowStartupLocation="CenterScreen"
WindowState="Maximized">
<ScrollViewer FlowDirection="RightToLeft"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<Grid x:Name="MainGrid"
FlowDirection="RightToLeft">
<Menu x:Name="menu"
HorizontalAlignment="Stretch"
Height="23"
VerticalAlignment="Top" />
<Grid Name="InnerGrid"
Margin="0,23,0,20" />
</Grid>
</ScrollViewer>
and I'm showing the usercontrol in the "InnerGrid"