XAML Avalonia DataGridTextColumn样式

oalqel3c  于 2023-09-28  发布在  其他
关注(0)|答案(1)|浏览(154)

我正在把项目从WPF.net6转移到Avalonia,我正在为datagridtextcolumn的样式化而挣扎。在纯WPF中,我的代码是:

<DataGridTextColumn Binding="{Binding Name}" Header="Имя" >
    <DataGridTextColumn.CellStyle>
        <Style TargetType="DataGridCell">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Label >
                            <Label.Content >
                                <MultiBinding Converter="{StaticResource TextBoxMiscConverter}">
                                    <Binding Path="Name" />
                                    <Binding Path="IsChecked" ElementName="ShowEnglishCbx" />
                                    <Binding Path="IsChecked" ElementName="ShowRussianCbx" />
                                </MultiBinding>
                            </Label.Content>
                        </Label>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </DataGridTextColumn.CellStyle>
</DataGridTextColumn>

在纯WPF中它工作得很好,但我找不到适合Avalonia的解决方案
我正在阅读avalonia文档,我找不到适当的解决方案。

bqujaahr

bqujaahr1#

找到了解决我的问题的方法:

<DataGridTextColumn Header="Имя" Binding="{Binding Name}" >
   <DataGridTextColumn.Binding>
      <MultiBinding Converter="{StaticResource TextBoxMiscConverter}">
         <Binding Path="Name" />
         <Binding Path="IsChecked" ElementName="EnglishTextChk" />
         <Binding Path="IsChecked" ElementName="CyrTextChk" />
      </MultiBinding>
   </DataGridTextColumn.Binding>
</DataGridTextColumn>

相关问题