开发者

WPF - Using same window for different functionality

I am planning 开发者_JAVA百科to develop a WPF application which manages different tasks. Each task contains set of input controls and output controls.

For this I need to have a reusable area on main window so that, without disturbing other UI elements on screen, I can update new set of controls on that reusable area.


I would recommend using a simple Grid or some such Panel-control. To change the content you would simply change it´s child user control or you might also set the DataContext to your view model (a data model describing whats to be displayed in your view) and then use a DataTemplate to display the DataContext as you like:

<Grid>
  <Grid.Resources>
  <DataTemplate DataType="{x:Type ViewModels:YourcurrentViewModel}">
      <StackPanel><TextBox Text="{Binding YourProperty}" /></StackPanel>
  </DataTemplate>
  </Grid.Resources>
</Grid>

There are a lot of resources out on this, just google DataTemplate or MVVM (Model View View-Model) pattern.


I like Almunds answer (upvoted) but I thought I'd chime in and add another few options. MVVM is the way to go, and frameworks like PRISM (supports MVVM) and to a lesser degree MEF allow for modular applications. I've seen this work in some trite practice demos, and it is sometimes overkill but it might be worth looking into if you want modular separation for your application.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜