开发者

MVVM Multiple Views same ViewModel in Prism

I have a question regarding multiple user controls views with the same view model type. I can't seems to find specific answers for my confusion but this is quite speculative.

I have.

    <StackPanel Orientation="Vertical">

        <TextBlock Text="Signature Summary" FontSize="14" FontWeight="Bold" TextAlignment="Center" Height="30"/>

        <my:ParameterFileSummaryView DataContext="{Binding ParamterFile1ViewModel}"/>

        <my:ParameterFileSummaryView DataContext="{Binding ParamterFile2ViewModel}"/>

        <my:ParameterFileSummaryView DataContext="{Binding ParamterFile3ViewModel}"/>

        <my:ParameterFileSummaryView DataContext="{Binding ParamterFile4ViewModel}"/>

        <my:ParameterFileSummaryView DataContext="{Binding ParamterFile5ViewModel}"/>

    </StackPanel>

the stack panel is a container inside a main view which has a dependancy property view model datacontext used for a Prism/Unity IoC architecture.

These are therefore binding the datacontect for these individual views to properties of the interface of the main view via another interface.

It all seems to work ok and the binding of the elements in the P开发者_JAVA百科arameterFileSummaryView bind nicely to the values set on the, say for the first one, ParamterFile1ViewModel.

Which is exactly what I want. But of cource these ViewModels are built within the ViewModel of the main window and not out of the Unity container.... It all feels a little bit hacky. Is there a cleaner way to implement what I am attempting.

Apologies if it is really a moot question... but I can't see the wood for the trees. If the question confuses I will add edits, please be patient I am not an expert :) .


Question answered by myself and sanity checked by @Jon... Sorry SO for cluttering your questions board.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜