Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
My First WPF App
Message
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01460394
Message ID:
01460479
Vues:
46
>I'm following this tutorial: http://msdn.microsoft.com/en-us/library/bb546972(v=VS.100).aspx
>
>I added the 3 controls called for under "Adding Controls to the Layout".
>
>The XAML looks like this:
>
>
><Window x:Class="FolderExplorer.MainWindow"
>        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
>        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>        Title="Folder Explorer" Height="400" Width="400">
>    <Grid>
>        <Grid.RowDefinitions>
>            <RowDefinition Height="200*" />
>            <RowDefinition Height="200*" />
>        </Grid.RowDefinitions>
>        <Grid.ColumnDefinitions>
>            <ColumnDefinition Width="200*" />
>            <ColumnDefinition Width="200*" />
>        </Grid.ColumnDefinitions>
>        <TreeView Height="71" HorizontalAlignment="Left" Margin="34,33,0,0" Name="treeView1" VerticalAlignment="Top" Width="120" />
>        <ListView Grid.Column="1" Height="100" HorizontalAlignment="Left" Margin="43,24,0,0" Name="listView1" VerticalAlignment="Top" Width="120" />
>        <ListView Grid.Column="1" Grid.Row="1" Height="100" HorizontalAlignment="Left" Margin="22,22,0,0" Name="listView2" VerticalAlignment="Top" Width="120" />
>    </Grid>
></Window>
>
>
>This does not appear as though the 3 controls are inside the grid's Rows/Columns. Did I do this right?

You're presumably talking about how the XAML looks rather than the actual behaviour of the window.
IAC, as others have said your XAML is correct. The controls to be included in the grid just need to be within their Grid's opening and closing tags (the order in which they occur is not important unless you are placing two items in the same grid cell).
The only bit I'd question is the '200*' values for the RowDefinitions (and ColumnDefinitions) which would actually be redundant since you're giving an equal amount of space to both which is the default anyway. If, for example, you wanted to divide the Grid so that the right column took up 2/3rds of the available space you could use '1*' and '2*' . For a left column using 5/8ths of the available space use '5*' and '3*' etc.
HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform