WPF

2013-06-26 5 views
0

에있는 에 사용할 수있는 대안이 있습니다. WPF에서 사용할 수있는 대안이 있습니다.이 태그의 특성은 특정 작업을 실행하기 전에 확인 대화 상자를 활성화합니다. WPF

이 태그는 실버 라이트에서 지원되지만 불행히도 WPF에서는이 태그가 빠져있는 것 같습니다. 이 프리즘 팀이 실수로 놓친 것이 있는지 확실하지 않습니다. 위의 태그에 가장 적합한 대안은 무엇입니까?

답변

1

기본적으로 나만의 것을 만들어야합니다. 그러나 이전에 발견 한 예가 있습니다. Prism의 상호 작용 클래스를 상당히 수정했기 때문에 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; 
    } 
} 
+0

고마워 @Alan 궁금했다. 도움이 필요한 것! – kuhajeyan

+0

호기심에 빠진이 질문을 프리즘 팀이 의도적으로 남겨두고 있는지 궁금해하십니까? – kuhajeyan

+1

@kbird "Silverlight의 경우 Prism 라이브러리는 PopupChildWindowAction 클래스를 제공합니다."라는 내용의 책이 의도적이라고 생각합니다. WPF 구현에서 제외하기로 결정한 이유가 확실하지 않습니다. – Alan