背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView
2021-05-12 22:27
标签:点击其他 mat 隐藏 express zed tle schema pat val [源码下载] 作者:webabcd 示例 Controls/LayoutControl/VariableSizedWrapGridDemo.xaml.cs Controls/LayoutControl/BorderDemo.xaml.cs Controls/LayoutControl/ViewboxDemo.xaml.cs Controls/LayoutControl/SplitViewDemo.xaml.cs OK 背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView 标签:点击其他 mat 隐藏 express zed tle schema pat val 原文地址:http://www.cnblogs.com/lonelyxmas/p/7567367.html
介绍
背水一战 Windows 10 之 控件(布局类)
1、VariableSizedWrapGrid 的示例
Controls/LayoutControl/VariableSizedWrapGridDemo.xamlPage
x:Class="Windows10.Controls.LayoutControl.VariableSizedWrapGridDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.LayoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
Grid Background="Transparent">
Grid Margin="5">
VariableSizedWrapGrid HorizontalAlignment="Left" Background="Green"
Orientation="Horizontal" MaximumRowsOrColumns="5"
ItemWidth="120" ItemHeight="120">
VariableSizedWrapGrid.Children>
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" VariableSizedWrapGrid.RowSpan="2" VariableSizedWrapGrid.ColumnSpan="2" />
Image Source="/Assets/StoreLogo.png" Margin="10" VariableSizedWrapGrid.ColumnSpan="3" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
Image Source="/Assets/StoreLogo.png" Margin="10" />
VariableSizedWrapGrid.Children>
VariableSizedWrapGrid>
Grid>
Grid>
Page>
/*
* VariableSizedWrapGrid - 用于 Wrap 子元素集合的控件(继承自 Panel, 请参见 /Controls/LayoutControl/PanelDemo.xaml)
*/
using Windows.UI.Xaml.Controls;
namespace Windows10.Controls.LayoutControl
{
public sealed partial class VariableSizedWrapGridDemo : Page
{
public VariableSizedWrapGridDemo()
{
this.InitializeComponent();
}
}
}
2、Border 的示例
Controls/LayoutControl/BorderDemo.xamlPage
x:Class="Windows10.Controls.LayoutControl.BorderDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.LayoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
Grid Background="Transparent">
StackPanel Margin="10 0 10 10">
Border Name="border1" Width="400" Height="100" HorizontalAlignment="Left" Margin="5"
BorderThickness="1,10,20,30" BorderBrush="Red" Background="Blue" CornerRadius="10" >
Border.Child>
TextBlock Text="我是 border1 里的内容" TextAlignment="Center" />
Border.Child>
Border>
Border Name="border2" Width="400" Height="100" HorizontalAlignment="Left" Margin="5">
TextBlock Text="我是 border2 里的内容" />
Border.ChildTransitions>
TransitionCollection>
EntranceThemeTransition />
TransitionCollection>
Border.ChildTransitions>
Border>
StackPanel>
Grid>
Page>
/*
* Border - 边框控件(继承自 FrameworkElement, 请参见 /Controls/BaseControl/FrameworkElementDemo.xaml)
*/
using Windows.UI.Xaml.Controls;
namespace Windows10.Controls.LayoutControl
{
public sealed partial class BorderDemo : Page
{
public BorderDemo()
{
this.InitializeComponent();
}
}
}
3、Viewbox 的示例
Controls/LayoutControl/ViewboxDemo.xamlPage
x:Class="Windows10.Controls.LayoutControl.ViewboxDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.LayoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
Grid Background="Transparent">
StackPanel Margin="10 0 10 10">
Border BorderBrush="Red" HorizontalAlignment="Left" BorderThickness="1" Width="100" Height="100" Margin="5">
Viewbox Width="100" Height="100" Stretch="Fill">
StackPanel>
TextBlock Text="webabcd" />
StackPanel>
Viewbox>
Border>
Border BorderBrush="Red" HorizontalAlignment="Left" BorderThickness="1" Width="100" Height="100" Margin="5">
Viewbox Width="100" Height="100" Stretch="None" >
StackPanel>
TextBlock Text="webabcd" />
StackPanel>
Viewbox>
Border>
Border BorderBrush="Red" HorizontalAlignment="Left" BorderThickness="1" Width="100" Height="100" Margin="5">
Viewbox Width="100" Height="100" Stretch="Uniform" >
StackPanel>
TextBlock Text="webabcd" />
StackPanel>
Viewbox>
Border>
Border BorderBrush="Red" HorizontalAlignment="Left" BorderThickness="1" Width="100" Height="100" Margin="5">
Viewbox Width="100" Height="100" Stretch="UniformToFill" >
StackPanel>
TextBlock Text="webabcd" />
StackPanel>
Viewbox>
Border>
StackPanel>
Grid>
Page>
/*
* Viewbox - 容器控件,用于控制子元素如何拉伸(继承自 FrameworkElement, 请参见 /Controls/BaseControl/FrameworkElementDemo.xaml)
*/
using Windows.UI.Xaml.Controls;
namespace Windows10.Controls.LayoutControl
{
public sealed partial class ViewboxDemo : Page
{
public ViewboxDemo()
{
this.InitializeComponent();
}
}
}
4、SplitView 的示例
Controls/LayoutControl/SplitViewDemo.xamlPage
x:Class="Windows10.Controls.LayoutControl.SplitViewDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.LayoutControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:common="using:Windows10.Common">
Page.Resources>
common:NullableBooleanToBooleanConverter x:Key="NullableBooleanToBooleanConverter" />
Page.Resources>
Grid Background="Transparent">
StackPanel Margin="10 0 10 10">
CheckBox Name="chkIsPaneOpen" Margin="5" Content="IsPaneOpen" IsChecked="True" />
ComboBox x:Name="cmbDisplayMode" Margin="5" PlaceholderText="DisplayMode" SelectionChanged="cmbDisplayMode_SelectionChanged">
ComboBoxItem>OverlayComboBoxItem>
ComboBoxItem>CompactOverlayComboBoxItem>
ComboBoxItem>InlineComboBoxItem>
ComboBoxItem>CompactInlineComboBoxItem>
ComboBox>
ComboBox x:Name="cmbPanePlacement" Margin="5" PlaceholderText="PanePlacement" SelectionChanged="cmbPanePlacement_SelectionChanged">
ComboBoxItem>LeftComboBoxItem>
ComboBoxItem>RightComboBoxItem>
ComboBox>
SplitView x:Name="splitView" Margin="5"
PaneBackground="#FF2B2B2B"
IsPaneOpen="{x:Bind chkIsPaneOpen.IsChecked, Mode=TwoWay, Converter={StaticResource NullableBooleanToBooleanConverter}}"
OpenPaneLength="320"
CompactPaneLength="48"
DisplayMode="Overlay"
PanePlacement="Left">
SplitView.Pane>
StackPanel Height="200">
TextBlock Text="我是 SplitView.Pane" />
StackPanel>
SplitView.Pane>
SplitView.Content>
StackPanel Height="200" Width="400" HorizontalAlignment="Left" Background="Orange">
TextBlock Text="SplitView.Content" />
StackPanel>
SplitView.Content>
SplitView>
StackPanel>
Grid>
Page>
/*
* SplitView - Pane/Content 控件(继承自 Control, 请参见 /Controls/BaseControl/ControlDemo/)
*/
using System;
using Windows.UI.Xaml.Controls;
namespace Windows10.Controls.LayoutControl
{
public sealed partial class SplitViewDemo : Page
{
public SplitViewDemo()
{
this.InitializeComponent();
}
private void cmbDisplayMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
splitView.DisplayMode = (SplitViewDisplayMode)Enum.Parse(typeof(SplitViewDisplayMode), (e.AddedItems[0] as ComboBoxItem).Content.ToString());
}
private void cmbPanePlacement_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
splitView.PanePlacement = (SplitViewPanePlacement)Enum.Parse(typeof(SplitViewPanePlacement), (e.AddedItems[0] as ComboBoxItem).Content.ToString());
}
}
}
[源码下载]
文章标题:背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView
文章链接:http://soscw.com/index.php/essay/84876.html