资源中的 XAML 边距 [英] XAML Margin in resources

查看:33
本文介绍了资源中的 XAML 边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Windows 通用应用资源中定义 XAML 边距?我试图将其定义为

How do I define XAML margin in Windows universal app resources? I tried to define it as

<Thickness x:Key="MyMargin" Left="10" Top="20" Right="10" Bottom="20" />

通过这个不编译,我得到

by this does not compile, I get

XamlCompiler 错误 WMC0100:无法构造 XAML 厚度类型.为了在 XAML 中构造,类型不能是抽象、接口、嵌套、泛型或结构,并且必须具有公共默认构造函数

XamlCompiler error WMC0100: XAML Thickness type cannot be constructed. In order to to be constructed in XAML, a type cannot be abstract, interface, nested, generic or a struct, and must have a public default constructor

推荐答案

Windows XAML 的语法如下:

The syntax for Windows XAML is as follows:

<Thickness x:Key="myMargin">10,20,10,20</Thickness>

可以简化为:

<Thickness x:Key="myMargin">10,20</Thickness>

这篇关于资源中的 XAML 边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆