将DataTemplate绑定字段设置为变量 [英] Setting DataTemplate Binding field as Variable
本文介绍了将DataTemplate绑定字段设置为变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
在我的datagrid中,我正在使用DataTemplate.我的疑问是如何将绑定路径设置为变量,以便可以从代码中传递该变量的值.下面是代码.这里的"Binding Path = Rate"行,其中"Rate"是一个常数项.我想将"Rate"作为变量,并希望从代码中提供值.例如:在代码Rate ="NewRate"中;任何想法.... ???
在此先感谢..... :) :) :) :)
Hi All
In my datagrid I am using a DataTemplate. My doubt is that how I can set the binding path as variable.So that I can pass the value for that variable from code. Below is the code. Here the line "Binding Path=Rate", where "Rate" is a constant term. I want to make the "Rate" as a variable and want to supply the value from code. Eg: in code Rate="NewRate"; Any Idea....???
Thanks in Advance..... :) :) :) :)
<UserControl.Resources><DataTemplate x:Key="RateControlTemplate">
<inputToolkit:Rating Background="Transparent" SelectionMode="Continuous" Name="RateControl" ValueChanged="Rating_ValueChanged" ItemCount="6" Value="{Binding Path=Rate, Mode=TwoWay}" VerticalAlignment="Center">
<inputToolkit:Rating.RenderTransform>
<ScaleTransform ScaleX=".75"
ScaleY="0.85" />
</inputToolkit:Rating.RenderTransform>
</inputToolkit:Rating>
</DataTemplate>
</UserControl.Resources>
推荐答案
您需要为数据网格提供数据上下文,然后在数据上下文中更改Rate值.
如果您使用INotify实现此功能,则您的用户界面将自动更新.
You need to provide a datacontext for the datagrid and then change the Rate value within the datacontext.
If you implement this with INotify, your UI will update automatically.
这篇关于将DataTemplate绑定字段设置为变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文