当前位置:网站首页>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。
边栏推荐
猜你喜欢

进行知识管理的好处有哪些?

crm系统哪家好?好用的crm管理系统推荐

【解决】虚拟机VMware通过局域网连接机器人no route to host

动态RDLC报表(一)

Account opening requirements and exemptions for special futures such as crude oil

2022秋招面试宝典,啃完面试稳了

程序员的专属浪漫——用3D Engine 5分钟实现烟花绽放效果

Fees and inquiry methods of futures account opening exchanges

动手学深度学习_风格迁移
![[Pycharm easy to use function]](/img/f8/4c131516033286ba8bcb511d395462.png)
[Pycharm easy to use function]
随机推荐
WPF 实现柱形统计图
Experience far more than Hue, this is the favorite SQL tool for technicians
ABP 6.0.0-rc.1的新特性
本机号码一键登录原理
leetcode300.最长递增子序列(动态规划)
[Code Audit] - PHP project class RCE and files include download and delete
记一次 .NET 某工控自动化控制系统 卡死分析
openEuler 熊伟:如何看待开源社区中的 SIG 组织模式?
API接口是什么?API接口常见的安全问题与安全措施有哪些?
What you should know about futures account opening
如何仿造一个websocket请求?
Lagrange interpolation formula matlab implementation
开篇-开启全新的.NET现代应用开发体验
win10 uwp 手动锁Bitlocker
.NET 6 study notes (4) - Solve the Nullable warning in VS2022
体验远超Hue,这才是技术人员最喜欢的SQL工具
International Soil Modeling Consortium-ISMC
总结篇4:redis 核心数据存储结构及核心业务模型实现应用场景
approach和method的区别
eyb:Redis学习(3)