Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZhangYuan authored Jan 14, 2020
1 parent 78d4776 commit ac6e2e7
Showing 1 changed file with 62 additions and 4 deletions.
66 changes: 62 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,69 @@ public MainWindow()
ViewManager.Instance.MainRichView.SwitchView(new MainView());
}
```
The second step is to initialize a Unicorn.ViewManager.Dialog or Unicorn.ViewManager.Flyout,you can inherit it in xaml,when you have a Unicorn.ViewManager.Dialog or Unicorn.ViewManager.Flyout, you can display it with ViewManager.Instance.Show(PopupItem item) method.
The second step is to initialize a Unicorn.ViewManager.Dialog or Unicorn.ViewManager.Flyout,you can inherit it in xaml,when you have a Unicorn.ViewManager.Dialog or Unicorn.ViewManager.Flyout,.
you can display it with ViewManager.Instance.Show(PopupItem item) method.
```csharp
ViewManager.Instance.Show(new FullScreenDialog());--FullScreenDialog is my Dialog instance inherit Dialog
--OR
ViewManager.Instance.Show(new LeftFlyout());--LeftFlyout is my flyout instance inherit Flyout
ViewManager.Instance.Show(new FullScreenDialog());//FullScreenDialog is my Dialog instance inherit Dialog
//OR
new FullScreenDialog().Show();//at default main view stack
//OR
new FullScreenDialog().Show(IPopupItemContainer );//IPopupItemContainer is a interface
//OR
new FullScreenDialog().ShowAsModal();//at default main view stack
//OR
new FullScreenDialog().ShowAsModal(IPopupItemContainer );//at custom IPopupItemContainer
```
you can close it like that.
```csharp
ViewManager.Instance.Close(Dialog dialog);//FullScreenDialog is my Dialog instance inherit Dialog
//OR
dialog.Close();
```

## View's events
Each view item has four events, they are 'Showing','Shown','Closing','Closed'.
'Showing','Closing' can be canceled. you can use it like that:
```csharp
public partial class DialogWithEvent
{
public DialogWithEvent()
{
InitializeComponent();
this.Showing += DialogWithEvent_Showing;
this.Shown += DialogWithEvent_Shown;
this.Closing += DialogWithEvent_Closing;
this.Closed += DialogWithEvent_Closed;
}

private void DialogWithEvent_Closed(object sender, EventArgs e)
{
MessageDialogBox.Show("该Dialog已彻底关闭,并已从视图栈移除,可在此事件处理中处理一些释放问题", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
}

private void DialogWithEvent_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
var msresult = MessageDialogBox.Show("Dialog With Event 准备关闭,此时可以取消,是否继续关闭", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (msresult == MessageBoxResult.No)
{
e.Cancel = true;
}
}

private void DialogWithEvent_Shown(object sender, EventArgs e)
{
MessageDialogBox.Show("该Dialog已显示完成,可在此事件处理中处理一些加载问题", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
}

private void DialogWithEvent_Showing(object sender, System.ComponentModel.CancelEventArgs e)
{
var msresult = MessageDialogBox.Show("Dialog With Event 准备显示,此时可以取消,是否继续显示", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (msresult == MessageBoxResult.No)
{
e.Cancel = true;
}
}
}
```
See more details in the demo.

Expand Down

0 comments on commit ac6e2e7

Please sign in to comment.