我想设置所有控件和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">
我确实理解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">
如何使用style为所有框架元素设置边距?