修改了按钮命令的绑定

This commit is contained in:
2025-08-23 20:58:48 +08:00
parent 6d2bc57923
commit c618d967df
3 changed files with 10 additions and 26 deletions

View File

@@ -29,14 +29,13 @@ public partial class DeviceDialogViewModel : DialogViewModelBase<DeviceItemViewM
}
[RelayCommand]
private async Task Save()
private async Task PrimaryButton()
{
// Here you can add validation logic before closing.
await Close(Device);
}
[RelayCommand]
private async Task Cancel()
private async Task CancleButton()
{
await Close(null);
}

View File

@@ -8,24 +8,16 @@
xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
xmlns:ex="clr-namespace:DMS.Extensions"
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:vc="clr-namespace:DMS.WPF.ValueConverts"
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButText}"
PrimaryButtonCommand="{Binding PrimaryButtonCommand}"
CloseButtonCommand="{Binding CancleButtonCommand}"
d:DataContext="{d:DesignInstance vmd:DeviceDialogViewModel}"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PrimaryButtonClick">
<i:InvokeCommandAction Command="{Binding SaveCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="CloseButtonClick">
<i:InvokeCommandAction Command="{Binding CancelCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ui:ContentDialog.Resources>
<ex:EnumBindingSource x:Key="DeviceType"
EnumType="{x:Type enums:DeviceType}" />
@@ -114,7 +106,7 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<StackPanel Background="LightGray">
<StackPanel.Style>
<Style TargetType="StackPanel">
@@ -131,9 +123,9 @@
HorizontalAlignment="Left"
Style="{StaticResource TextBlockSubTitle}" />
<TextBox Text="{Binding Device.OpcUaServerUrl}"/>
</StackPanel>
</StackPanel>
<!-- S7 Specific Properties -->
<StackPanel x:Name="S7PropertiesPanel" Background="LightGray">
<StackPanel.Style>

View File

@@ -10,23 +10,16 @@
xmlns:en="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
Title="{Binding Title}"
CloseButtonText="取消"
DefaultButton="Primary"
PrimaryButtonText="{Binding PrimaryButText}"
PrimaryButtonCommand="{Binding PrimaryButtonCommand}"
CloseButtonCommand="{Binding CancleButtonCommand}"
Background="#fff"
d:DataContext="{d:DesignInstance vmd:VariableDialogViewModel}"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PrimaryButtonClick">
<i:InvokeCommandAction Command="{Binding PrimaryButtonCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="CloseButtonClick">
<i:InvokeCommandAction Command="{Binding CancleButtonCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ui:ContentDialog.Resources>
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
</ui:ContentDialog.Resources>