- <Window x:Class="WpfApplication2.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="MainWindow" Height="447" Width="631">
- <Grid>
- <TabControl Height="272" HorizontalAlignment="Left" Margin="49,58,0,0" Name="tabControl1" VerticalAlignment="Top" Width="312">
- <TabItem Header="tabItem1" Name="tabItem1">
- <Grid>
- <DataGrid AutoGenerateColumns="False" Height="228" HorizontalAlignment="Left" Margin="6,6,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="290" />
- </Grid>
- </TabItem>
- </TabControl>
- </Grid>
- </Window>
Ovenstående giver et vindue, med en TabControl med én tab, og som har et grid.
Prøver du at tilføje dit grid fra codebehind, skal du gøre:
- <Window x:Class="WpfApplication2.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="MainWindow" Height="447" Width="631">
- <Grid>
- <TabControl Height="272" HorizontalAlignment="Left" Margin="49,58,0,0" Name="tabControl1" VerticalAlignment="Top" Width="312">
- <TabItem Header="tabItem1" Name="tabItem1">
- <Grid Name="tab1">
-
- </Grid>
- </TabItem>
- </TabControl>
- </Grid>
- </Window>
- //Antaget du har oprettet et Grid med navnet grid
- this.tab1.Children.Add(grid);