当前位置:网站首页>win10 uwp 自定义控件 SplitViewItem
win10 uwp 自定义控件 SplitViewItem
2022-08-09 16:53:00 【林德熙】
本文主要是因为汉堡菜单里面列出的菜单很多重复的图标和文字,我把它作为控件,因为是随便写,可能存在错误,如果发现了,请和我说或关掉浏览器,请不要发不良言论。
我们使用汉堡菜单,经常需要一个
需要一个图标和一个文字
我开始写一个TextBlock做图标,一个写文字
<ListViewItem.Content>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10,10,10,10" FontFamily="Segoe MDL2 Assets"
Text=""></TextBlock>
<TextBlock Margin="10,10,10,10" Text="登录"></TextBlock>
</StackPanel>
</ListViewItem.Content>因为需要写3个地方是不一样,一个是文字、一个图标还有一次复制,我觉得复制不好,因为我还有很多软件,如果每个都这样,那么在TextBlock使用
很多都是一样的
一个方法是自己创建控件,我们右击View文件夹添加控件
在控件写两个TextBlock,一个做图标,一个写文字
<Grid>
<StackPanel Orientation="Horizontal">
<TextBlock Margin="10,10,10,10" FontFamily="Segoe MDL2 Assets"
Text="{x:Bind IconString}"></TextBlock>
<TextBlock Margin="10,10,10,10" Text="{x:Bind Text}"></TextBlock>
</StackPanel>
</Grid>然后在SplitViewItem.xaml.cs
属性IconString,Text
public static readonly DependencyProperty IconStringProperty = DependencyProperty.Register(
"IconString", typeof(string), typeof(SplitViewItem), new PropertyMetadata(default(string)));
public string IconString
{
set
{
SetValue(IconStringProperty, value);
}
get
{
return (string) GetValue(IconStringProperty);
}
}
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
"Text", typeof(string), typeof(SplitViewItem), new PropertyMetadata(default(string)));
public string Text
{
set
{
SetValue(TextProperty, value);
}
get
{
return (string) GetValue(TextProperty);
}
}我把SplitViewItem扔View文件夹,在命名空间使用EncryptionSyncFolder.View
` xmlns:view=”using:EncryptionSyncFolder.View”`
本来需要很长的代码,现在修改成为一点点,其实就是导入我的自定义控件,首先在上面的代码是把view用作我的控件所在文件夹,反人类的Segoe MDL2 Assets 可以在http://modernicons.io/segoe-mdl2/cheatsheet/,找到你要的图标
<ListViewItem>
<ListViewItem.Content>
<Grid>
<view:SplitViewItem IconString="" Text="设置"></view:SplitViewItem>
</Grid>
</ListViewItem.Content>
</ListViewItem>SplitView 从右划出
修改PanelPlacement。
边栏推荐
猜你喜欢

重谈联想5G编码投票事件

What you should know about futures account opening

《.NET物联网从零开始》系列

【Pycharm好用功能】

Discuz! Forum program installation + template configuration tutorial

【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点

The principle implementation of handwritten flexible.js, I finally understand the multi-terminal adaptation of the mobile terminal

What is hardware integrated development?What are the cores of hardware integrated development?
In-depth understanding of MySQL common data types and data type selection optimization

方舟开服务器Vmware虚拟机安装不上?
随机推荐
传统数据中台又贵又复杂?何不试一试永久免费的下一代数据中台
动态RDLC报表(七)
uniapp电影购票选座系统源码
【燃】是时候展现真正的实力了!一文看懂2022华为开发者大赛技术亮点
How to choose a good SaaS knowledge base tool?
十七、一起学习Lua 错误处理
方舟:生存进化开服务器端口映射教程
Experience far more than Hue, this is the favorite SQL tool for technicians
搭建Zabbix监控系统
dotnet 6 为什么网络请求不跟随系统网络代理变化而动态切换代理
【机器学习】回归树生成过程及举例理解
史上最全架构师知识图谱
.NET 6学习笔记(4)——解决VS2022中Nullable警告
About the common Hook encapsulation of DOM (2)
最强分布式锁工具:Redisson
What platform is EPIC?
An in-depth understanding of the implementation principle of Hybrid
Metasploit——辅助模块(Auxiliary)
国际土壤模型协会 International Soil Modeling Consortium-ISMC
Detailed explanation of JVM memory model and structure (five model diagrams)