在将列设为可编辑模式之前,DataGridTextcolumn的绑定文本中的数据不会显示 [英] Data in a Binded Text of DataGridTextcolumn does not appear un till Making the Column in editable Mode
问题描述
伙计们
我有一个带有称为税款"的列的数据网格,当我在此列bu用户中键入任何内容时,我在此列上创建了一种样式来管理我的火灾事件(文本已更改),我成功完成了此操作,但是现在当我在该列中键入时事件我想要的问题是,只有在列处于可编辑模式下时,我在列中键入的数据才会出现,否则数据消失了,我该如何解决该问题?
在高级感谢
我的代码:-
hi guys
i have a data grid with columns Called Taxes i made a style to this Column to manage me Fire Event (Text Changed) when any thing Typed in this Column bu user , i succeed in doing that but now when i type in the column it fire the Event As i Want , the problem is the data i typed in the column does not Appear only if the Column is in editable mode else the data disappear , how can i solve that
thanks in advanced
My code :-
<datagridtextcolumn loc:translate.uid="1629" header="{loc:Translate Taxes}" width="Auto" xmlns:loc="#unknown">
<datagridtextcolumn.editingelementstyle>
<Style TargetType="TextBox">
<setter>
<setter.property>
Text
</setter.property>
<setter.value>
<binding>
<binding.path>Tax</binding.path>
<binding.mode>TwoWay</binding.mode>
<binding.updatesourcetrigger>PropertyChanged</binding.updatesourcetrigger>
</binding>
</setter.value>
</setter>
<eventsetter event="TextChanged" handler="Txt_Tax_TextChanged" />
</Style>
</datagridtextcolumn.editingelementstyle>
</datagridtextcolumn>
private void Txt_Tax_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
this.UpdateTotal();
}
catch
{
}
}
推荐答案
您应将TextColumn绑定到codebehind/viewmodel中的属性.然后,在该财产的设置工中,您可以适当地增加税收.像这样的东西:-
You should bind your TextColumn to a property in the codebehind/viewmodel. Then in the setter for that property you can increase the taxes appropriately. Something like this :-
<datagridtextcolumn binding="{Binding" path="Tax}/"></datagridtextcolumn>
并在您后面的代码中
and in your code behind
decimal tax;
decimal totalTaxes;
public decimal Tax
{
get { return tax; }
set
{
if (tax == value) return;
tax = value;
totalTaxes += value;
OnPropertyChanged("Tax");
}
}
希望对您有帮助
Hope that helps
这篇关于在将列设为可编辑模式之前,DataGridTextcolumn的绑定文本中的数据不会显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!