设为首页 收藏本站
查看: 666|回复: 0

[经验分享] 背水一战 Windows 10 (39)

[复制链接]

尚未签到

发表于 2017-6-29 11:09:54 | 显示全部楼层 |阅读模式
  [源码下载]




背水一战 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[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());
}
}
}
  
OK
[源码下载]

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-389266-1-1.html 上篇帖子: Windows下Apache部署Django过程记录 下篇帖子: 将node.js程序作为服务,并在windows下开机自动启动(使用forever)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表