English 中文(简体)
WPF , MVVM , MasterDetail 页 次
原标题:WPF , MVVM , MasterDetailPage
  • 时间:2012-01-15 18:12:45
  •  标签:
  • c#
  • wpf
  • mvvm

I got a MasterPageuserControl, 其中载有3个用户控制(和3个浏览器)。

MasterView:
 -> MenuView (-> MenuViewModel )
 -> InfoView (-> InfoViewModel )
 -> SliderView (-> SliderViewModel )

In slider view i got a list Box with SelectedItem Propertyed to a SelectedItem Property in the view model (SliderViewModel)

当选定系统发生变化时,即想将其全部用于InfoViewModel和更新InfoView。

我可以做这样的事情,即我多次打赢,但想最佳实践模式。

另一个小问题是,还是应该为总意见页树立一个看法吗? 虽然这并不包含把3个用户控制起来的任何偏差。

您的帮助将受到高度赞赏。

最佳回答

我不相信在这种情形下最优秀的职称考试和测验科,但我可以考虑通过考试和测验科这样做。

页: 1 MasterViewModel,揭开主人的财产 在其他观点模式之间交流的观点。 和

class MasterViewModel
{
    MenuViewModel;
    InfoViewModel;
    SliderViewModel;

    public CommunicationProperty 
    {
       set
       {
       InforViewModel.SomeProperty = value;
       }
    }
}

class SliderViewModel
{
    pubic SliderViewModel(MasterViewModel masterViewModel)
    {
        //hold reference of master view model in a variable  
    }

    public SelectedItem
    {
        set
        {
            // change the info view model via master view model
            masterViewModel.CommunicationProperty = value;
        }
    }
}
问题回答

选择很少:

  1. You may declare SelectedItem as dependency property in your view model class (if it is inherited from DependencyObject)
  2. You may declare SelectedItem as regular property and make your view model class to implement INotifyPropertyChanged interface and fire PropertyChanged event in setter.

计生联有许多新概念,但仍通过事件与商业逻辑进行沟通。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签