WPF / xaml如何绑定到Horizo​​ntalAlignment

时间:2018-07-17 19:28:43

标签: wpf binding

要绑定到什么内容以操纵Horizo​​ntalAlignment?传递一个简单的字符串似乎不起作用,但是我找不到一个示例。

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>

0 个答案:

没有答案