WPF DataGridTemplateColumn组合框更新所有行 [英] WPF DataGridTemplateColumn combobox updating all rows

查看:317
本文介绍了WPF DataGridTemplateColumn组合框更新所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的XAML选择从组合框的的ItemSource是一个枚举值。我使用的教程是:

I have this XAML that selects a value from a combobox that the ItemSource is a Enum. The tutorial I used is:

http://www.c-sharpcorner.com/uploadfile/dpatra/combobox-in-datagrid-in-wpf/

            <DataGrid x:Name="dgProductItem" 
                   ItemsSource="{Binding ProductVersion.ProductItems}"

            <DataGridTemplateColumn Header="Deployment Type" Width="120">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding DeploymentType}"></TextBlock>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding Source={StaticResource DeploymentTypeEnum}}"
                                  SelectedItem="{Binding DeploymentType}">

                        </ComboBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>



然而,当我从一个行更改值,将更新所有行。 ?有谁知道这是为什么。

However when I change a value from one row, it will update all the rows. Does anyone know why this is?

编辑:

如果我只是改变一个行,只会更新该行,但是当我去改变不同的行,该行我只是改变也将改变以往的..

if I just change one row, it will only update that row, but when I go to change a different row, that row I just changed will also change the previous one..

干杯

推荐答案

Aplogises的重复,但猜测了几个小时后,因为网络上有不是足够材料,这有点儿东西,解决的办法是

Aplogises for the duplicates but after a few hours of guessing because there isnt enough material on the web for this kinda stuff, the solution is

                </DataGridTemplateColumn.CellTemplate>
                <DataGridTemplateColumn.CellEditingTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding Source={StaticResource DeploymentTypeEnum}}"
                                  SelectedItem="{Binding DeploymentType}"
                                  **IsSynchronizedWithCurrentItem="false**">
                        </ComboBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellEditingTemplate>



IsSynchronizedWithCurrentItem - 做什么它在锡说。然而,当你选择一个项目,目前一会消失,但至少它不会更新的所有行。

IsSynchronizedWithCurrentItem - does what it says on the tin. However, when you select an item, the current one will disappear but at least it wont update all rows.

这篇关于WPF DataGridTemplateColumn组合框更新所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆