Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF/xaml如何绑定到水平对齐_Wpf_Binding - Fatal编程技术网

WPF/xaml如何绑定到水平对齐

WPF/xaml如何绑定到水平对齐,wpf,binding,Wpf,Binding,我将绑定到什么,操纵水平对齐?传递一个简单的字符串似乎不起作用,但我找不到一个什么起作用的例子 private string _CategoryHorizontalAlignment; public string CategoryHorizontalAlignment { get { return _CategoryHorizontalAlignment; } set { _CategoryHorizontalAli

我将绑定到什么,操纵水平对齐?传递一个简单的字符串似乎不起作用,但我找不到一个什么起作用的例子

private string _CategoryHorizontalAlignment;
public string CategoryHorizontalAlignment
    {
        get { return _CategoryHorizontalAlignment; }
        set
        {
            _CategoryHorizontalAlignment = value;
            NotifyPropertyChanged("CategoryHorizontalAlignment");
        }
    }

...
<ControlTemplate TargetType="Label">
       <Border x:Name="_brdMain" 
               BorderThickness="{TemplateBinding BorderThickness}"
               BorderBrush="{TemplateBinding BorderBrush}" 
               Background="{TemplateBinding Background}"
               CornerRadius="7,7,7,7" Padding="{Binding CategoryPadding, UpdateSourceTrigger=PropertyChanged}">
           <ContentPresenter  HorizontalAlignment="{Binding CategoryHorizontalAlignment, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" />
       </Border>
</ControlTemplate>
private string\u CategoryHorizontalAlignment;
公共字符串类别横向对齐
{
获取{return\u CategoryHorizontalAlignment;}
设置
{
_类别水平对齐=值;
NotifyPropertyChanged(“类别横向对齐”);
}
}
...

请看一看。属性的类型为,而不是字符串。还要注意,在绑定上设置
UpdateSourceTrigger=PropertyChanged
是没有意义的。它在这里不起作用。当用非兼容属性进行数据绑定时(如果使用类型),如果需要,还可以考虑使用转换器(),这里也可以帮助您:谢谢。水平对齐属性是我所缺少的。