WPF的TabControl和DataGrid错误,错误和错误 [英] WPF TabControl and DataGrid bugs, bugs and bugs

查看:469
本文介绍了WPF的TabControl和DataGrid错误,错误和错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给大家,我发现WPF的的TabControl并且DataGrid不同的问题。特别是如果的TabControl的ItemsSource必然。

for everyone, I found different problems with WPF, the TabControl and the DataGrid. Especially if the TabControl ItemsSource is bound.

问题,我发现:


  • 选择DataGrid中切换标签来回后不可见

  • DataGrid中失去标签开关排序(CollectionView.GetDefaultCollection的SortDescriptions上卸载清零)

  • 如果DataGrid单元格具有焦点(处于编辑模式)并单击另一个选项卡上,有两种情况:1)的约束对象将不会被更新。 2)如果对象是无效的您会收到编辑过程中DeferRefresh不允许出错,或者像这样

  • DataGridComboBox和其他可能的控制做,如果你切换到另一个选项卡如果您正在使用绑定和的TabControls工作的DataTemplates清除其值。这将清除任何选择。

所以现在我的问题:有没有在这种情况下更好地执行任何第三方控件

So now my question: Is there any ThirdParty controls which perform better in this scenarios?

您还可以在这里投票的http://connect.microsoft.com/VisualStudio/feedback/details/807849/databound-tabcontrol-bugs

我得到的答案来自微软也不会解决,因为没有足够的人都有这样的问题。
我知道有一些修正,但他们有一些非常不干净(使用F.E.反射)。也许你有一些想法?

I got answer from Microsoft it won't fix because not enough people have this problems. I know some fixes, but they are some really not clean (f.e. using reflection). Maybe you have some ideas?

推荐答案

我有同样的问题。

修复,DataGridComboBox问题可能是指定组合框一样DataGrid的是从视觉树中删除了TabControl的,而不是DataGrid的DataContext属性的的ItemsSource当您选择另一个标签:

Fix to DataGridComboBox issue may be to specify the ItemsSource of the ComboBox as the DataContext property of the TabControl instead of the DataGrid as the DataGrid is removed from the visual tree when you select another tab:

    <TabControl x:Name="tabControl" Behaviours:TabContent.IsCached="True">
        <TabItem Header="Tab1" Content="{Binding}" ContentTemplate="{StaticResource Tab1}"/>
        <TabItem Header="Tab2" Content="{Binding}" ContentTemplate="{StaticResource Tab2}"/>
    </TabControl>

    <DataTemplate x:Key="Tab1">
        <DataGrid ItemsSource="{Binding Entities}" x:Name="dataGrid">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="100"/>
                <DataGridTemplateColumn Header="Position" Width="150">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Position}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox SelectedItem="{Binding Position, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                                      ItemsSource="{Binding Path=DataContext.Positions, ElementName=tabControl}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellEditingTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </DataTemplate>

这篇关于WPF的TabControl和DataGrid错误,错误和错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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