使用Prism和MVVM时WindowState更改

时间:2012-04-04 10:19:12

标签: mvvm prism

类似于问题中提到的情景:Binding the "WindowState" property of a window in WPF using MVVM

使用Prism(视图,模块,shell) 我有一个Shell.xaml(属于WPFProject),按顺序加载2个视图:

  1. 来自SecurityModule的LoginView.xaml(usercontrol)(另一个类库项目)
  2. 来自ProductModule的MainScreenView.xaml(usercontrol)(另一个classlibrary项目) - 点击LoginView.xaml上的“登录”按钮
  3. LoginView.xaml更小,如width = 300,height = 300。但是MainScreenView.xaml需要以最大化的尺寸显示。

    现在要在shell上显示MainScreenView.xaml,需要最大化windowstate。

    如何公开Shell WindowState属性,以便在使用Prism和MVVM在shell上加载视图时可以更改?

    请参阅链接中的Prism MVVM示例示例:http://weblogs.asp.net/sujithkjagini/archive/2011/02/02/building-applications-with-wpf-and-prism-aka-cag.aspx

1 个答案:

答案 0 :(得分:0)

一个简单的解决方案是使用Prism事件。 Prism包含一个EventAggregator,它允许模块之间的通信。您可以在帖子中链接的页面末尾找到一个示例,但可能不太清楚。这个其他链接可能会帮助您link