繁体   English   中英

将ViewModel直接绑定到扩展WPF工具包PropertyGrid

[英]Binding a ViewModel directly to an Extended WPF Toolkit PropertyGrid

我想将ViewModel直接绑定到PropertyGrid,而ViewModel不必包含对其自身的引用。 即目前我有:

<xctk:PropertyGrid SelectedObject="{Binding ViewModel}">

在ViewModel中,我有:

public class WatcherBaseViewModel : ObservableObject 
{
    [Browsable(false)]
    // Do I really need this?
    public WatcherBaseViewModel ViewModel
    {
        get { return this; }
    }

    // Rest of class removed for clarity
 }

既然这行得通,那都是非常学术性的,但是简洁是机智的灵魂,也是所有人的灵魂……我有什么办法可以在XAML绑定中直接引用ViewModel?

删除Path表单绑定,因为它将指向已经是WatcherBaseViewModel DataContext

<xctk:PropertyGrid SelectedObject="{Binding}">

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM