views:

316

answers:

3

Hi,

I have a listview of width set to Auto. When I run the windows app, it opens in normal size(not maximized). But when I maximize the window, the listview's width will be same and the space to its right is empty.

normal size |_____________________| Maximized |_____________________|...........

even though the window is now in full screen occupied. Please guide me in workin on this.

Thanks Ramm

A: 

Well, I believe that by default the ListView control automatically fills all available space so it is very strange that have such an issue. Could you paste your code?

Milan Nankov
A: 

Hi..

the stack panel xaml code ::

            <StackPanel Name="spDataFlow" Orientation="Horizontal" Margin="0,45,0,0" >
                        <StackPanel x:Name="stkPnlDataFlow"  Orientation="Vertical" VerticalAlignment="Top">

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />

                                </Grid.RowDefinitions>
                            </Grid>

                            <StackPanel Grid.Row="1" Margin="20,15,0,0" Orientation="Horizontal"  VerticalAlignment="Center" >
                                <RadioButton Name="rdbtnUploadData" HorizontalAlignment="Left"  VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Upload Data" IsEnabled="True"  Checked="rdbtn_Checked" CommandParameter="UploadAll"/>
                                <RadioButton Name="rdbtnDownloadData" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Download Data" Margin="20,0" Checked="rdbtn_Checked"  CommandParameter="DownloadAll"/>
                                <RadioButton Name="rdbtnUploadSelected" HorizontalAlignment="Left"  VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Update Data" Margin="10,0" Checked="rdbtn_Checked" CommandParameter="UpdateSelected"/>
                            </StackPanel>
                        </StackPanel>
                </StackPanel>

when the app runs.. if the window is in custom size, it looks fine. when the window is maximized, it wont stretches it to fit the page.

Please help me Thanks Ramm

Aditya
+1  A: 

StackPanel, by design, does not care about visual space. It aims to take up the smallest amount of space possible. You can leave the innermost StackPanel that wraps the radio buttons in place, but your outer layout containers should be changed to Grid or, as in my example below, DockPanel:

<Window x:Class="Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="445" Width="515">

    <DockPanel Name="spDataFlow" Margin="0,45,0,0" >
        <DockPanel x:Name="stkPnlDataFlow" VerticalAlignment="Top">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />

                </Grid.RowDefinitions>
            </Grid>

            <StackPanel Grid.Row="1" Background="Red" Margin="20,15,0,0" Orientation="Horizontal"  VerticalAlignment="Center" >
                <RadioButton Name="rdbtnUploadData" HorizontalAlignment="Left"  VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Upload Data" IsEnabled="True"  CommandParameter="UploadAll"/>
                <RadioButton Name="rdbtnDownloadData" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Download Data" Margin="20,0" CommandParameter="DownloadAll"/>
                <RadioButton Name="rdbtnUploadSelected" HorizontalAlignment="Left"  VerticalAlignment="Center" FontSize="12" Foreground="White" Content="Update Data" Margin="10,0"  CommandParameter="UpdateSelected"/>
            </StackPanel>

        </DockPanel>
    </DockPanel>

</Window>
Rob Sobers
Hi Rob, thanks for the help.. But somehow this couldnt work out.I still have blank area on right of the screenthanksramm
Aditya
What do you want to occupy that space? Do you want the radio buttons to be spread far apart? If that's the case, you have to replace the inner-most StackPanel.
Rob Sobers