Reputation: 2188
I am still new to VS, C# and XAML. I have this code below
<Window x:Class="KANASoft___Xplora.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen" Icon="folder.gif" ResizeMode="CanResizeWithGrip"
Title="KANASoft - Xplora" Height="700" Width="535" Background="Black" Name="mainWindow">
<Grid Height="{Binding ElementName=mainWindow, Path=Height}" Width="{Binding ElementName=mainWindow, Path=Width}">
<ListBox Background="Black" Name="LBHeader" BorderBrush="Aqua" ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="0 0 0 1" Height="80" VerticalAlignment="Top">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Width="{Binding ElementName=mainWindow, Path=Width}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
</Window>
I want my <ListBox Name="LBHeader">
to resize according to the window's width when the window is resized and it works fine when I resize the window by dragging the window edges.
But the problem is that when I maximize the window, the <ListBox Name="LBHeader">
doesn't resize with the window.
Please I need help on this.
Upvotes: 0
Views: 157
Reputation: 340
You should remove the Height and Width
attributes from the Grid
, and the WrapPanel
.
Upvotes: 2
Reputation: 439
I searched for you and found this: C# windows form for all screen size With resize Controls and Positioning Hopes it will help you
Upvotes: 0