开发者

WPF BindingGroup for GridView

I have a GridView that I would like users to edit as much as they want, but not to save any changes back to the binding object until the user clicks the save button. For textboxes and such I have used binding groups, but this approach does not seem to work for the GridView.

What 开发者_开发百科is the best approach for delayed edits for the entire grid?


'UpdateSourceTrigger' may be what you are after. Have a look at http://msdn.microsoft.com/en-us/library/system.windows.data.binding.updatesourcetrigger.aspx. Set the UpdateSourceTrigger in the binding to Explicit, then call UpdateSource in the button click event.

Here is an example with a TextBox:

<TextBox Name="tb1"
     Text="{Binding Path=ItemName, UpdateSourceTrigger=Explicit}" />

And the code:

BindingExpression be = tb1.GetBindingExpression(TextBox.TextProperty); 
be.UpdateSource();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜