0
在WPF中是否有其他可用選項,此標記的性質是在執行任何特定操作之前啓用確認對話框。是否有其他替代方法可用於WPF中的<prism:popupwindowacion>
這個標籤在silverlight下支持,但不幸的是它好像在WPF下丟失了。不知道這個棱鏡團隊意外錯過了什麼。上述標籤的最佳選擇是什麼?
在WPF中是否有其他可用選項,此標記的性質是在執行任何特定操作之前啓用確認對話框。是否有其他替代方法可用於WPF中的<prism:popupwindowacion>
這個標籤在silverlight下支持,但不幸的是它好像在WPF下丟失了。不知道這個棱鏡團隊意外錯過了什麼。上述標籤的最佳選擇是什麼?
你基本上必須創建自己的。但是,有一個例子是我之前找到的人做的。我對Prism的Interaction類進行了相當多的修改,所以我的ModalPopupAction可能與你需要的有所不同。所以相反,看看這個鏈接並下載他的例子。它有一個WPF實現!
Prism: InteractionRequest and PopupModalWindowAction for WPF applications
而如果你想知道......我的ModalPopupAction看起來像這樣(但它需要一些其他類礦井)
public class ModalPopupAction : TriggerAction<FrameworkElement>
{
public UserControl InteractionView
{
get { return (UserControl)GetValue(InteractionViewProperty); }
set { SetValue(InteractionViewProperty, value); }
}
// Using a DependencyProperty as the backing store for PopupDialog. This enables animation, styling, binding, etc...
public static readonly DependencyProperty InteractionViewProperty =
DependencyProperty.Register("InteractionView", typeof(UserControl), typeof(ModalPopupAction), new UIPropertyMetadata(null));
protected override void Invoke(object parameter)
{
InteractionRequestedEventArgs args = parameter as InteractionRequestedEventArgs;
if (args == null)
return;
// create the window
ModalPopupDialog dialog = new ModalPopupDialog();
dialog.Content = InteractionView;
// set the data context
dialog.DataContext = args.Interaction;
// handle finished event
EventHandler handler = null;
handler = (o, e) =>
{
dialog.Close();
args.Callback();
};
args.Interaction.Finished += handler;
// center window
DependencyObject current = AssociatedObject;
while (current != null)
{
if (current is Window)
break;
current = LogicalTreeHelper.GetParent(current);
}
if (current != null)
dialog.Owner = (current as Window);
dialog.ShowDialog();
dialog.Content = null;
dialog.DataContext = null;
args.Interaction.Finished -= handler;
}
}
非常感謝@Alan。這幫助了需要的東西! – kuhajeyan
有點好奇心,想知道這是Prism團隊有意將這件事留下嗎? – kuhajeyan
@kbird我認爲這是故意的,因爲這本書說「對於Silverlight,棱鏡庫提供了PopupChildWindowAction類。」我不確定他們爲什麼決定放棄WPF實施 – Alan