이 하나가 나와 함께 노는 것이고, 알아낼 수없는 것처럼 보입니다.WPF - PRISM : 버튼 클릭으로 CustomPopupWindow를 닫는 방법
우리는 직접 스타일을 지정하고 팝업 화면에 사용자 정의 닫기 버튼을 추가하기 때문에 버튼이 최소화되고 최대화되고 닫히는 팝업 창이 필요합니다.
https://msdn.microsoft.com/en-us/library/ff921081(v=pandp.40).aspx https://msdn.microsoft.com/en-us/library/gg405494(v=pandp.40).aspx https://www.codeproject.com/Articles/269364/MVVM-PRISM-Modal-Windows-by-using-Interaction-Requ
을하지만 난 아직도 이것을 달성하는 방법을 알아낼 수 없습니다 : 내가 지금있는 곳
그래서 내가 얻을이 링크를 따라 갔다. 기본 창에는 "OK"및 "Cancel"버튼이 있지만 기본 설정이므로 원하지 않습니다. 그래서 "사용자 정의보기"방식을 사용했습니다. 여기<Window x:Class="Prototype.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:views="clr-namespace:Prototype.Views"
Height="349.146" Width="727.317"
WindowState="Maximized">
<Grid>
<Button Command="{Binding RaiseCustomPopupViewCommand}">Show Popup Window</Button>
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding CustomPopupViewRequest, Mode=OneWay}">
<prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
<prism:PopupWindowAction.WindowStyle>
<Style TargetType="Window">
<Setter Property="ShowInTaskbar" Value="False"/>
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="ResizeMode" Value="NoResize"/>
</Style>
</prism:PopupWindowAction.WindowStyle>
<prism:PopupWindowAction.WindowContent>
<views:CustomPopupView />
</prism:PopupWindowAction.WindowContent>
</prism:PopupWindowAction>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
</Grid>
</Window>
그리고 메인 윈도우의 코드 :
은 여기 내 메인 윈도우의 XAML입니다public class MainWindowViewModel : BindableBase
{
public InteractionRequest<INotification> CustomPopupViewRequest { get; private set; }
public MainWindowViewModel()
{
CustomPopupViewRequest = new InteractionRequest<INotification>();
}
public DelegateCommand RaiseCustomPopupViewCommand => new DelegateCommand(RaiseCustomPopupView, CanRaiseCustomPopupView);
public string InteractionResultMessage { get; private set; }
private void RaiseCustomPopupView()
{
InteractionResultMessage = "";
CustomPopupViewRequest.Raise(new Notification { Content = "Message for the CustomPopupView", Title = "Custom Popup" });
}
private bool CanRaiseCustomPopupView()
{
return true;
}
}
InteractionRequestTrigger
의 SourceObject는 UserControl이 있습니다. 그래서
<UserControl x:Class="Prototype.Views.CustomPopupView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"
xmlns:local="clr-namespace:Prototype.Views"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
MinWidth="300" MinHeight="100">
<StackPanel Orientation="Vertical" Background="Gray">
<Button DockPanel.Dock="Right"
Content="Close"/>
</StackPanel>
</UserControl>
당신이 볼 수 있듯이, 내가 UserControl을에서 "닫기"버튼이 있습니다
는 여기가 XAML의입니다.
커맨드를 사용해 보았습니다 만, 그때까지도 윈도우에 액세스 할 수 없거나 윈도우를 닫을 수 없습니다.
프리즘 명령이나 내가 모르는 뭔가가 있습니까?
버튼을 사용하여 원하는대로 창을 닫을 수 있습니까?
도움이 될 것입니다. :)
당신이 당신의 자신의 문제를 해결했음을 알았습니다. FYI, Prism의 최신 문서는 http://prismlibrary.readthedocs.io/en/latest/에서 찾을 수 있습니다. MSDN 문서를 사용할 필요가 없습니다. –