English 中文(简体)
数据网 窗口损失的项目。 IsEnabled = 虚假
原标题:Datagrid SelectedItem lost on window.IsEnabled = false

我有(主要)<条码>。 载有<代码>Frame。 缩略语

观点有一些数据网,其中一环是视像,另一组则与选定的数据网相联。 页: 1

问题发生在我展示一个人口箱时,把主窗IsEnabled = 伪造。 发生这种情况时,从数据网中挑选的、受电离模型约束的项目未经选定,当然其他数据网选定的项目也未当选。

在我的主要窗口时,我怎么能保持“状态”。 能否被弄错?

问题回答

如果你想要增加这种混合的某种不便。 在安装了VS2011 Beta(将NET 4.0框架改为 )。 NET 4.5 我创建了一个小型测试应用程序,其目标为<4.0>/strong>,而且如果电网残疾,其行为已再次改变,不再将选定的电算线设定为无效。 我不知道这是否会使它成为最后版本4.5。

数据网的内在行为似乎是在数据网残疾时淡化选定项目——刚刚核实这一点。

但试图这样做:

编制简略清单,增加一些数据,选定一个项目,点击一个县,以解脱名单。 如果选定项目获得选用,那么这一行为就由人民论坛设计。 我认为,你做的事情不多。 除不妨碍你的控制外......

如果选定项目没有获选,你就可以在“联通”上开张。 可能需要几个月的时间才能得到答复,“远见”在几年内出现。 如果这种等待不是一种选择,那么也就在WPF工具包中张贴了一张标语(参看编码x.com)。 该工具包可能很快得到更新。

这是预期的行为,也是设计的,但无论出乎意料,还是令人厌恶的,许多人认为,应当删除。 着手创建新的<代码>DataGrid类别,继承<代码>DataGrid,从而改变了这一活动的行为。

<>XAML

<DataGrid x:Class="MyDataGrid"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d">
</DataGrid>

<><>Code Behind

public partial class MyDataGrid : DataGrid
{
  public MyDataGrid()
  {
    InitializeComponent();
  }

  static MyDataGrid()
  {
    IsEnabledProperty.OverrideMetadata(
      typeof(MyDataGrid), 
      new FrameworkPropertyMetadata(OnIsEnabledChanged));
  }

  private static void OnIsEnabledChanged(
    DependencyObject d, 
    DependencyPropertyChangedEventArgs e)
  {
    d.CoerceValue(CanUserAddRowsProperty);
    d.CoerceValue(CanUserDeleteRowsProperty);

    CommandManager.InvalidateRequerySuggested();
  }
}





相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签