背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView
作者:webabcd
介绍
背水一战 Windows 10 之 控件(布局类)
- VariableSizedWrapGrid
- Border
- Viewbox
- SplitView
示例
1、VariableSizedWrapGrid 的示例
Controls/LayoutControl/VariableSizedWrapGridDemo.xaml
<Page
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 - 用于 Wrap 子元素集合的控件
Orientation - 控件内元素的排列方向
Horizontal - 水平排列
Vertical - 垂直排列
MaximumRowsOrColumns - 最大行数或最大列数(默认值为 -1)
ItemWidth - 每个 item 的宽度(默认值为 double.NaN)
ItemHeight - 每个 item 的高度(默认值为 double.NaN)
HorizontalChildrenAlignment - 看不出有啥用
VerticalChildrenAlignment - 看不出有啥用 VariableSizedWrapGrid.RowSpan - 合并的行数(附加属性)
code-behind: int GetRowSpan(UIElement element), SetRowSpan(UIElement element, int value)
VariableSizedWrapGrid.ColumnSpan - 合并的列数(附加属性)
code-behind: int GetColumnSpan(UIElement element), SetColumnSpan(UIElement element, int value)
--> <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>
Controls/LayoutControl/VariableSizedWrapGridDemo.xaml.cs
/*
* 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.xaml
<Page
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 - 边框控件
Child - 边框里的内容([ContentProperty(Name = "Child")])
BorderThickness - 边框的宽度(像素值:上下左右;左右,上下;左,上,右,下)
注:边框控件的边框是绘制在控件内部的
BorderBrush - 边框的画笔
Background - 边框里内容的背景画笔
CornerRadius - 边框角的半径(左上 右上 右下 左下)
ChildTransitions - 过渡效果集合
--> <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 里的内容会有 EntranceThemeTransition 的主题过渡效果-->
<Border.ChildTransitions>
<TransitionCollection>
<EntranceThemeTransition />
</TransitionCollection>
</Border.ChildTransitions>
</Border> </StackPanel>
</Grid>
</Page>
Controls/LayoutControl/BorderDemo.xaml.cs
/*
* 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.xaml
<Page
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"> <!--
Viewbox - 容器控件,用于控制子元素如何拉伸
Child - 容器里的内容([ContentProperty(Name = "Child")])
Stretch - 拉伸方式(Windows.UI.Xaml.Media.Stretch 枚举)
Fill - 充满容器,不保留长宽比
None - 不做任何处理,如果内容比容器大,则多出的部分被剪裁
Uniform - 等比缩放到容器(默认值)
UniformToFill - 充满容器,且保留长宽比,多出的部分被剪裁 StretchDirection - 如何决定是否放大或缩小(Windows.UI.Xaml.Controls.StretchDirection 枚举)
UpOnly - 需要的时候执行放大操作,永远不会执行缩小操作
DownOnly - 需要的时候执行缩小操作,永远不会执行放大操作
Both - 需要的时候即可执行放大操作,又可执行缩小操作(默认值)
--> <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>
Controls/LayoutControl/ViewboxDemo.xaml.cs
/*
* 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.xaml
<Page
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>Overlay</ComboBoxItem>
<ComboBoxItem>CompactOverlay</ComboBoxItem>
<ComboBoxItem>Inline</ComboBoxItem>
<ComboBoxItem>CompactInline</ComboBoxItem>
</ComboBox> <ComboBox x:Name="cmbPanePlacement" Margin="5" PlaceholderText="PanePlacement" SelectionChanged="cmbPanePlacement_SelectionChanged">
<ComboBoxItem>Left</ComboBoxItem>
<ComboBoxItem>Right</ComboBoxItem>
</ComboBox> <!--
SplitView - Pane/Content 控件
Pane - 导航视图
Content - 内容视图([ContentProperty(Name = "Content")])
PaneBackground - 导航视图的背景画笔
IsPaneOpen - 是否显示导航视图(默认值为 true)
OpenPaneLength - 导航视图完全展开时的宽度(默认值为 320)
CompactPaneLength - 紧凑模式下导航视图的宽度(默认值为 48)
PanePlacement - 导航视图相对于内容视图的显示位置
Left - 导航视图显示在内容视图的左侧(默认值)
Right - 导航视图显示在内容视图的右侧
DisplayMode - 显示方式
Overlay - 导航视图打开时,其会覆盖在内容视图上面(点击其他区域会自动关闭);导航视图关闭时,其会隐藏
CompactOverlay - 导航视图打开时,其会覆盖在内容视图上面(点击其他区域会自动关闭);导航视图关闭时,其会以紧凑模式显示
Inline - 导航视图打开时,其会以与内容视图并行显示(点击其他区域不会自动关闭);导航视图关闭时,其会隐藏
CompactInline - 导航视图打开时,其会以与内容视图并行显示(点击其他区域不会自动关闭);导航视图关闭时,其会以紧凑模式显示
PaneClosing - 导航视图准备关闭时触发的事件
PaneClosed - 导航视图关闭后触发的事件
--> <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>
Controls/LayoutControl/SplitViewDemo.xaml.cs
/*
* 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[] as ComboBoxItem).Content.ToString());
} private void cmbPanePlacement_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
splitView.PanePlacement = (SplitViewPanePlacement)Enum.Parse(typeof(SplitViewPanePlacement), (e.AddedItems[] as ComboBoxItem).Content.ToString());
}
}
}
OK
[源码下载]
背水一战 Windows 10 (39) - 控件(布局类): VariableSizedWrapGrid, Border, Viewbox, SplitView的更多相关文章
- 背水一战 Windows 10 (38) - 控件(布局类): Panel, Canvas, RelativePanel, StackPanel, Grid
[源码下载] 背水一战 Windows 10 (38) - 控件(布局类): Panel, Canvas, RelativePanel, StackPanel, Grid 作者:webabcd 介绍背 ...
- 背水一战 Windows 10 (72) - 控件(控件基类): UIElement - UIElement 的位置, UIElement 的布局, UIElement 的其他特性
[源码下载] 背水一战 Windows 10 (72) - 控件(控件基类): UIElement - UIElement 的位置, UIElement 的布局, UIElement 的其他特性 作者 ...
- 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing
[源码下载] 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing 作者:webabcd 介绍背水一 ...
- 背水一战 Windows 10 (75) - 控件(控件基类): FrameworkElement - 基础知识, 相关事件, HorizontalAlignment, VerticalAlignment
[源码下载] 背水一战 Windows 10 (75) - 控件(控件基类): FrameworkElement - 基础知识, 相关事件, HorizontalAlignment, Vertical ...
- 背水一战 Windows 10 (54) - 控件(集合类): ItemsControl 的布局控件 - OrientedVirtualizingPanel, VirtualizingStackPanel, WrapGrid
[源码下载] 背水一战 Windows 10 (54) - 控件(集合类): ItemsControl 的布局控件 - OrientedVirtualizingPanel, VirtualizingS ...
- 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog
[源码下载] 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog 作者:webabcd 介绍背水一战 Windows 10 之 控 ...
- 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu
[源码下载] 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu 作者:webabcd 介绍背水一战 Windows 10 之 控件(弹 ...
- 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout
[源码下载] 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout 作者:webabcd 介绍背水一战 Windows 10 之 ...
- 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
[源码下载] 背水一战 Windows 10 (33) - 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch 作者:webabcd 介绍背水一 ...
随机推荐
- Spring之SpringMVC前端控制器DispatcherServlet(源码)分析
1.DispatcherServlet作用说明 DispatcherServlet提供Spring Web MVC的集中访问点,而且负责职责的分派,而且与Spring IoC容器无缝集成,从而可以获得 ...
- Get Resultset from Oracle Stored procedure
http://stackoverflow.com/questions/1170548/get-resultset-from-oracle-stored-procedure
- ASP.NET MVC + EF 利用存储过程读取大数据
ASP.NET MVC + EF 利用存储过程读取大数据,1亿数据测试很OK 看到本文的标题,相信你会忍不住进来看看! 没错,本文要讲的就是这个重量级的东西,这个不仅仅支持单表查询,更能支持连接查询, ...
- iOS基础 - 数据库CoreData
一.iOS应用数据存取的常用方式 XML属性列表 —— PList NSKeyedArchiver 归档 Preference(偏好设置) SQLite3 Core Data 二.Core Data简 ...
- 浅谈DevExpress<二>:设计一个完整界面(2)
下面来把剩下的工作做完,换肤功能昨天已近讨论过,今天就不重复了.首先建立三个全局变量,一个存放文件路径,一个存放数据,一个存放过滤条件. string DBFileName; DataView dat ...
- Android学习笔记-Intent(一)
Intent对象在Android官方API这样描述:It is a passive data structure holding an abstract description of an opera ...
- facebook .net sdk 应用
浅谈 facebook .net sdk 应用 今天看了一篇非常好的文章,就放在这里与大家分享一下,顺便也给自己留一份.这段时间一直在学习MVC,另外如果大家有什么好的建议或者学习的地方,也请告知 ...
- C/C++基础知识总结——数据的共享与保护
1. 标识符的作用域与可见性 1.1 作用域 标识符的作用域包括:函数原型作用域.局部作用域.类作用域.命名空间作用域 (1) 函数原型作用域:函数的参与的作用域就是从函数的开始到结束 (2) 局部作 ...
- [转]使用ReactiveCocoa实现iOS平台响应式编程
原文:http://www.itiger.me/?p=38 使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍 ...
- CentOS安装Python教程
下载/安装python yum install -y bzip2* #nodejs 0.8.5需要,请安装python前,先安装此模块. wget http://www.python.org/ft ...