Ver código fonte

添加onload事件

user_lt 1 ano atrás
pai
commit
c2246edcf5

+ 13 - 2
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/QueryViewModel.cs

@@ -46,15 +46,24 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             QueryCommand = new DelegateCommand<object>(Query);
             ResetCommand = new DelegateCommand<object>(Reset);
             ExportCommand = new DelegateCommand<string>(Export);
+            OnLoadCommand = new DelegateCommand(OnLoad);
             GetConfigOption();
-            GetContent();
+          
         }
 
 
 
 
-        #region 私有方法
 
+
+        #region 私有方法
+        /// <summary>
+        /// 每次进入页面加载
+        /// </summary>
+        private void OnLoad()
+        {
+            GetContent();
+        }
         private void Reset(object obj)
         {
             ScheduleName = string.Empty;
@@ -263,7 +272,9 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
     
         public DelegateCommand<string> ExportCommand { set; get; }
 
+        public DelegateCommand OnLoadCommand { set; get; }
         
+
         #endregion
         #region 数据绑定
         /// <summary>

+ 6 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/QueryView.xaml

@@ -7,9 +7,15 @@
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
             <RowDefinition Height="40"/>
             <RowDefinition Height="40"/>