فهرست منبع

Form - 工具栏取消选中

chenrongqian 2 سال پیش
والد
کامیت
73c73484ce
2فایلهای تغییر یافته به همراه63 افزوده شده و 2 حذف شده
  1. 25 1
      PDF Office/Views/Form/FormsToolContent.xaml
  2. 38 1
      PDF Office/Views/Form/FormsToolContent.xaml.cs

+ 25 - 1
PDF Office/Views/Form/FormsToolContent.xaml

@@ -14,6 +14,8 @@
     d:DesignHeight="40"
     d:DesignHeight="40"
     d:DesignWidth="800"
     d:DesignWidth="800"
     prism:ViewModelLocator.AutoWireViewModel="True"
     prism:ViewModelLocator.AutoWireViewModel="True"
+    Loaded="UserControl_Loaded"
+    Unloaded="UserControl_Unloaded"
     mc:Ignorable="d">
     mc:Ignorable="d">
     <UserControl.Resources>
     <UserControl.Resources>
         <convert:UnVisivleConvert x:Key="UnVisibleConvert" />
         <convert:UnVisivleConvert x:Key="UnVisibleConvert" />
@@ -36,8 +38,9 @@
             <Setter Property="Fill" Value="{StaticResource color.icon.base.neutral.norm.lv2}" />
             <Setter Property="Fill" Value="{StaticResource color.icon.base.neutral.norm.lv2}" />
         </Style>
         </Style>
     </UserControl.Resources>
     </UserControl.Resources>
+   
     <Grid VerticalAlignment="Center">
     <Grid VerticalAlignment="Center">
-        <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
+        <StackPanel x:Name="PnlTool" HorizontalAlignment="Center" Orientation="Horizontal">
             <RadioButton>
             <RadioButton>
                 <Grid>
                 <Grid>
                     <Path Data="M3 4H18C18.2761 4 18.5 4.22386 18.5 4.5V11L13.5 16H3C2.72386 16 2.5 15.7761 2.5 15.5V4.5C2.5 4.22386 2.72386 4 3 4ZM0.5 4.5C0.5 3.11929 1.61929 2 3 2H18C19.3807 2 20.5 3.11929 20.5 4.5V15.5C20.5 16.8807 19.3807 18 18 18H3C1.61929 18 0.5 16.8807 0.5 15.5V4.5Z" Style="{StaticResource BorderPath}" />
                     <Path Data="M3 4H18C18.2761 4 18.5 4.22386 18.5 4.5V11L13.5 16H3C2.72386 16 2.5 15.7761 2.5 15.5V4.5C2.5 4.22386 2.72386 4 3 4ZM0.5 4.5C0.5 3.11929 1.61929 2 3 2H18C19.3807 2 20.5 3.11929 20.5 4.5V15.5C20.5 16.8807 19.3807 18 18 18H3C1.61929 18 0.5 16.8807 0.5 15.5V4.5Z" Style="{StaticResource BorderPath}" />
@@ -47,6 +50,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Text" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Text" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="Text" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -58,6 +64,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="CheckBox" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="CheckBox" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="CheckBox" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -76,6 +85,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="RadioButton" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="RadioButton" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="RadioButton" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -87,6 +99,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="ListBox" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="ListBox" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="ListBox" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -98,6 +113,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Combox" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Combox" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="Combox" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -110,6 +128,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Button" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Button" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="Button" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
             <RadioButton>
             <RadioButton>
@@ -120,6 +141,9 @@
                     <i:EventTrigger EventName="Checked">
                     <i:EventTrigger EventName="Checked">
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Sign" />
                         <i:InvokeCommandAction Command="{Binding CheckedCommand}" CommandParameter="Sign" />
                     </i:EventTrigger>
                     </i:EventTrigger>
+                    <i:EventTrigger EventName="Click">
+                        <i:InvokeCommandAction Command="{Binding ClickCommand}" CommandParameter="Sign" />
+                    </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
             </RadioButton>
             </RadioButton>
 
 

+ 38 - 1
PDF Office/Views/Form/FormsToolContent.xaml.cs

@@ -1,4 +1,5 @@
-using System;
+using PDF_Office.ViewModels.Form;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
@@ -20,6 +21,7 @@ namespace PDF_Office.Views.Form
     /// </summary>
     /// </summary>
     public partial class FormsToolContent : UserControl
     public partial class FormsToolContent : UserControl
     {
     {
+        private FormsToolContentViewModel ViewModel =>DataContext as FormsToolContentViewModel;
         public FormsToolContent()
         public FormsToolContent()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -53,5 +55,40 @@ namespace PDF_Office.Views.Form
             //取消右键菜单的绑定,只能左键点击弹出
             //取消右键菜单的绑定,只能左键点击弹出
             this.BtnMore.ContextMenu = null;
             this.BtnMore.ContextMenu = null;
         }
         }
+
+        private void UserControl_Loaded(object sender, RoutedEventArgs e)
+        {
+            if(ViewModel != null)
+            {
+                ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
+                ViewModel.UncheckedToolsBtnEvent += ViewModel_UncheckedToolsBtnEvent;
+            }
+            
+        }
+
+        private void ViewModel_UncheckedToolsBtnEvent(object sender, string e)
+        {
+            foreach(var item in PnlTool.Children)
+            {
+                var btn = item as RadioButton;
+                if (btn != null)
+                {
+                    if (btn.IsChecked == true)
+                    {
+                        btn.IsChecked = false;
+                        break;
+                    }
+                }
+            }
+        }
+
+        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
+        {
+            if (ViewModel != null)
+            {
+                ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent;
+            }
+
+        }
     }
     }
 }
 }