在Silverlight中使用GridSplitter

组件所在命名空间:System.Windows.Controls

 

方法一:不使用Toolkit

引入命名空间:

xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"

 <UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" BorderThickness="3,10" BorderBrush="#FFEB0F97" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="760" > <!-- This is the Grid for the entire page. --> <Grid Background="White"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <!-- This is the nested Grid on the left. It isn't subdivided further with a splitter. --> <Grid Grid.Column="0" VerticalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Button Margin="3" Grid.Row="0" Content="Top Left"></Button> <Button Margin="3" Grid.Row="1" Content="Bottom Left"></Button> </Grid> <!-- This is the vertical splitter that sits between the two nested (left and right) grids. --> <controls:GridSplitter Grid.Column="1" Background="LightGray" Width="3" HorizontalAlignment="Center" VerticalAlignment="Stretch"> </controls:GridSplitter> <!-- This is the nested Grid on the right. --> <Grid Grid.Column="2"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Button Grid.Row="0" Margin="3" Content="Top Right"></Button> <Button Grid.Row="2" Margin="3" Content="Bottom Right"></Button> <!-- This is the horizontal splitter that subdivides it into a top and bottom region.. --> <controls:GridSplitter Grid.Row="1" Background="LightGray" Height="3" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="False"></controls:GridSplitter> </Grid> </Grid> </UserControl>   

 

方法二:安装了Toolkit

引入命名空间:

xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"

<UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" BorderThickness="3,10" BorderBrush="#FFEB0F97" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="760" > <!-- This is the Grid for the entire page. --> <Grid Background="White"> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <!-- This is the nested Grid on the left. It isn't subdivided further with a splitter. --> <Grid Grid.Column="0" VerticalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Button Margin="3" Grid.Row="0" Content="Top Left"></Button> <Button Margin="3" Grid.Row="1" Content="Bottom Left"></Button> </Grid> <!-- This is the vertical splitter that sits between the two nested (left and right) grids. --> <sdk:GridSplitter Grid.Column="1" Background="LightGray" Width="3" HorizontalAlignment="Center" VerticalAlignment="Stretch"> </sdk:GridSplitter> <!-- This is the nested Grid on the right. --> <Grid Grid.Column="2"> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Button Grid.Row="0" Margin="3" Content="Top Right"></Button> <Button Grid.Row="2" Margin="3" Content="Bottom Right"></Button> <!-- This is the horizontal splitter that subdivides it into a top and bottom region.. --> <sdk:GridSplitter Grid.Row="1" Background="LightGray" Height="3" VerticalAlignment="Center" HorizontalAlignment="Stretch" ShowsPreview="False"></sdk:GridSplitter> </Grid> </Grid> </UserControl>       

 

Toolkit下载地址:

官方网站:http://silverlight.codeplex.com/

你可能感兴趣的:(在Silverlight中使用GridSplitter)