光之远征团跨服战

使用WPF样式设置所有控件和文本块的边距

我想设置所有控件和TextBlocks使用样式的边距。以下是未使用样式的我的窗口XAML:

代码语言:javascript复制

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d"

Title="Window2" Height="150" Width="300">

Test

这是预期的结果:

我确实理解TextBlock是FrameWorkElement,而TextBox & Button是一个控件(这是一个FrameWorkElement)。FrameWorkElement上引入了边距属性,因此我尝试在FrameWorkElement上设置边距,但没有成功:

代码语言:javascript复制

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d"

Title="Window2" Height="150" Width="300">

Test

如何使用style为所有框架元素设置边距?

十二星座与枪支:各星座偏爱哪种枪械?
躾中文是什么意思


最新发表

友情链接