110,536
社区成员
发帖
与我相关
我的任务
分享
public InteractionRequest<Confirmation> ShowMessageBoxRequest { get; set; }
//MessageBox.Show("请选择设备");
ShowMessageBoxRequest.Raise(new Confirmation() { Title = "提示", Content = "请选择设备" }, (Confirmed) => { return; });
xmlns:prism="http://www.codeplex.com/prism"
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding ShowMessageBoxRequest, Mode=OneWay}">
<prism:PopupChildWindowAction ContentTemplate="{StaticResource ConfirmWindowTemplate}"/>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
<i:Interaction.Triggers>
<prism:InteractionRequestTrigger SourceObject="{Binding ShowOKMessageBoxRequest}">
<ta:ShowOKMessageBoxTriggerAction/>
</prism:InteractionRequestTrigger>
</i:Interaction.Triggers>
public class ShowOKMessageBoxTriggerAction : TriggerAction<FrameworkElement>
{
protected override void Invoke(object parameter)
{
InteractionRequestedEventArgs interactionRequestedEventArgs = parameter as InteractionRequestedEventArgs;
if (interactionRequestedEventArgs != null)
{
Confirmation confirmation = interactionRequestedEventArgs.Context as Confirmation;
if (confirmation != null)
{
MessageBoxContent messageBoxContent = confirmation.Content as MessageBoxContent;
if (messageBoxContent != null)
{
MessageBox.Show(App.Current.MainWindow, messageBoxContent.content, confirmation.Title, MessageBoxButton.OK, messageBoxContent.messageBoxImage);
confirmation.Confirmed = true;
interactionRequestedEventArgs.Callback?.Invoke();
}
}
}
}
}
public InteractionRequest<Confirmation> ShowOKMessageBoxRequest { get; set; }
void InvokeShowOKMessageBoxRequest(string content, MessageBoxImage messageBoxImage)
{
ShowOKMessageBoxRequest.Raise(new Confirmation()
{
Title = "提示",
Content = new MessageBoxContent()
{
content = content,
messageBoxImage = messageBoxImage
}
});
}
public ICommand AppendUSBCAN2Command
{
get
{
return new DelegateCommand(() =>
{
if (CurrentSerial == null)
{
InvokeShowOKMessageBoxRequest("请选择设备", MessageBoxImage.Error);
return;
}
if (CurrentChannel_USBCAN2 == null)
{
InvokeShowOKMessageBoxRequest("请选择设通道", MessageBoxImage.Error);
return;
}
ControllerParam controllerParam = hardwareHelper.CreateDefaultParam_USBCAN2();
controllerParam.Serial = CurrentSerial;
controllerParam.Channel = CurrentChannel_USBCAN2.ID; // 1 - 通道1,2 - 通道2
hardwareHelper.AddController(controllerParam);
ControllerParamList = new ObservableCollection<ControllerParam>(hardwareHelper.ControllerParamList);
});
}
}