gpt4 book ai didi

wpf - DataGridTextColumn值更改时如何更改DataGridCheckBoxColumn值?

转载 作者:行者123 更新时间:2023-12-03 10:38:37 28 4
gpt4 key购买 nike

我正在将wpf与mvvm一起使用,并且我有一个4列的datagrid:
ID,原始,已翻译,已翻译
我想当“翻译”列中的文本更改时,“IsTranslated”列的值自动更改为选中
这是我的datagrid xaml代码:

<DataGrid Grid.Row="3" AutoGenerateColumns="False" ItemsSource="{Binding AllXliffs}">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Path=Id}" />
<DataGridTextColumn Header="Original" Binding="{Binding Path=Original}" />
<DataGridTextColumn Header="Translated" Binding="{Binding Path=Translated}" />
<DataGridCheckBoxColumn Header="IsTranslated" Binding="{Binding Path=IsTranslated, Mode=TwoWay, Converter={StaticResource StringToBooleanConverter}, UpdateSourceTrigger=PropertyChanged}" ></DataGridCheckBoxColumn>
</DataGrid.Columns>
</DataGrid>

最佳答案

由于您正在使用MVVM,因此可以在model属性中添加小型业务逻辑:

像这样 :

        private string _translation;
private bool _isTranslated;

public string Translation
{
get { return _translation; }
set
{
_translation = value;
IsTranslated = !String.IsNullOrEmpty(_translation);
}
}

public bool IsTranslated
{
get { return _isTranslated; }
set
{
_isTranslated = value;
OnPropertyChanged("IsTranslated");
}
}

关于wpf - DataGridTextColumn值更改时如何更改DataGridCheckBoxColumn值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14425619/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com