添加多绑定转换器以及内容到按钮 wpf

Add Multibinding converter as well as content to a button wpf

在我的 wpf 项目中我有:

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <Button Background="Transparent" Foreground="#E43D47" materialDesign:RippleAssist.IsDisabled="True" BorderBrush="Transparent">
            <Style TargetType="Button" BasedOn="{StaticResource MaterialDesignFlatButton}">
                <Setter Property="Foreground">
                    <Setter.Value>
                        <MultiBinding>
                            <MultiBinding.Converter>
                                <local:ProxyStatusForeground/>
                            </MultiBinding.Converter>
                            <Binding RelativeSource="{RelativeSource Self}" Path="Column.Header"/>
                            <Binding/>
                            <Binding Path="HasChanges"/>
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <TextBlock Text="⚫"/>
                        </ControlTemplate>

                    </Setter.Value>
                </Setter>
            </Style>
        </Button>
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

我想将此按钮绑定到我的 multibinding.converter 以及将 ⚫ 作为文本,以便我可以更改它的前景。如果我这样做(我在 Datagrid Header 中这样做),每当我添加一行时,它都会显示 System.Windows.Styles 而不是 ⚫。我怎么能做到这一点?如有任何帮助,我们将不胜感激!

您添加了 Style 作为 Button.Content 的值(这将在 Style 实例上隐式调用 object.ToString(),这将 return类型的限定名称):

<Button>
  <!-- this is setting the Content property -->
  Some Text
</Button>

等于

<Button Content="Some Text" />

Style 必须是 Button.Style 属性 的值:

<Button>
  <Button.Style>
    <Style TargetType="Button">
      ...
    </Style>
  </Button.Style>
</Button>