开发者

Scope of Popup and InteractionRequest in Prism

I need clarification on when to use Pop-up, InteractionRequest. Here is my scenario.

I have left side navigation view which displays the Folder's in tree format (as same as Windows Directory). I should allow the user to Add, Rename and Remove the directory by using context menu. For Add and Rename operation, it should popup a window with "TextBox" for user input and should have "Save" and "Cancel" button. For Remove option, if should ask for confirmation.

What should i do for Add/Rename operation?

  1. Create simple Window (with user input TextBox , Save and Cancel Button) without ViewModel. Save and Cancel Button click will set the DialogResult flag and close the win开发者_如何学Pythondow.

  2. Create simple Window (with user input TextBox , Save and Cancel Button) with ViewModel. Save and Cancel button click will be handled in ViewModel (This look bit tedious since very limited code).

  3. Is there any alternative way to handle this?

What should i do for Remove Operation?

  1. I will go for InteractionRequest

  2. I will go for Customized Window (Dialog) which will be called as like MessageBox, without popup or InteractionRequest(ie from view model => MyMessageBox.Show(.....) == Dialog.Ok..

please give me the right solution.


Since your Popup is so small, I would actually create a DataTemplate inside your current View and just bind the Add/Rename/Remove commands to the same ViewModel.

I like using my own custom Popup, because I've had many issues with WPF's popup's in the past. It is generally used like this:

<Grid Name="RootPanel">

    <DockPanel>
        <TreeView DockPanel.Dock="Right" />
        // <!-- Other Window Content -->
    </DockPanel>

    <local:PopupPanel
        local:PopupPanel.PopupParent="{Binding ElementName=RootPanel}"
        local:PopupPanel.IsPopupVisible="{Binding IsPopupVisible}"

        local:PopupPanel.BackgroundOpacity=".5"
        local:PopupPanel.PopupEnterKeyCommand="{Binding SaveCommand}"
        local:PopupPanel.PopupEscapeKeyCommand="{Binding CancelCommand}">

        // Put whatever you want for Popup Content here

        // Usually I have a property in my ViewModel for PopupContent, and 
        // will put a ContentControl here that uses a different ContentTemplate 
        // based on what type of object is in PopupContent
    </local:PopupPanel>

</Grid>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜