Pārlūkot izejas kodu

修改richtextbox

user_lt 1 gadu atpakaļ
vecāks
revīzija
2924beccf1

+ 5 - 22
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditSchView.xaml

@@ -86,14 +86,8 @@
                 <Grid Grid.Row="2">
                     <DockPanel LastChildFill="True" >
                         <TextBlock Text="前置项描述:"   Style="{StaticResource textBlockStyle}" />
-                        <RichTextBox  Margin="0,5,5,5" >
-                            <FlowDocument>
-                                <Paragraph>
-                                    <Run Text="{Binding BeforeDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
-                                </Paragraph>
-                            </FlowDocument>
-
-                        </RichTextBox>
+                        <TextBox x:Name="txtBefore"  TextWrapping="Wrap"  Text="{Binding BeforeDetail }"  AcceptsReturn="True" KeyDown="txtBefore_KeyDown"/>
+                      
                     </DockPanel>
                 </Grid>
             </Grid>
@@ -174,14 +168,8 @@
                 <Grid Grid.Row="2">
                     <DockPanel LastChildFill="True" >
                         <TextBlock Text="输入项描述:"   Style="{StaticResource textBlockStyle}" />
-                        <RichTextBox  Margin="0,5,5,5" >
-                            <FlowDocument>
-                                <Paragraph>
-                                    <Run Text="{Binding InDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
-                                </Paragraph>
-                            </FlowDocument>
+                        <TextBox x:Name="txtIn"  TextWrapping="Wrap"  Text="{Binding InDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  AcceptsReturn="True" KeyDown="txtIn_KeyDown"/>
 
-                        </RichTextBox>
                     </DockPanel>
                 </Grid>
             </Grid>
@@ -263,14 +251,9 @@
                 <Grid Grid.Row="2">
                     <DockPanel LastChildFill="True" >
                         <TextBlock Text="结果项描述:"   Style="{StaticResource textBlockStyle}" />
-                        <RichTextBox  Margin="0,5,5,5" >
-                            <FlowDocument>
-                                <Paragraph>
-                                    <Run Text="{Binding OutDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
-                                </Paragraph>
-                            </FlowDocument>
+                  
+                        <TextBox x:Name="txtOut"  TextWrapping="Wrap"  Text="{Binding OutDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  AcceptsReturn="True" KeyDown="txtOut_KeyDown"/>
 
-                        </RichTextBox>
                     </DockPanel>
                 </Grid>
             </Grid>

+ 37 - 0
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditSchView.xaml.cs

@@ -24,5 +24,42 @@ namespace PLCTool.Views.BasicConfigView
         {
             InitializeComponent();
         }
+
+        private void txtBefore_KeyDown(object sender, KeyEventArgs e)
+        {
+            var textbox = sender as TextBox;
+            if (e.Key == Key.Enter &&
+                !(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) &&
+                !(Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.LeftShift)))
+            {
+                textbox.Text = "";
+                e.Handled = true;
+            }
+        }
+
+        private void txtIn_KeyDown(object sender, KeyEventArgs e)
+        {
+            var textbox = sender as TextBox;
+            if (e.Key == Key.Enter &&
+                !(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) &&
+                !(Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.LeftShift)))
+            {
+                textbox.Text = "";
+                e.Handled = true;
+            }
+        }
+
+        private void txtOut_KeyDown(object sender, KeyEventArgs e)
+        {
+            var textbox = sender as TextBox;
+            if (e.Key == Key.Enter &&
+                !(Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) &&
+                !(Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.LeftShift)))
+            {
+                textbox.Text = "";
+                e.Handled = true;
+            }
+
+        }
     }
 }

+ 1 - 1
BlankApp1/BlankApp1/Views/MainWindow.xaml

@@ -149,7 +149,7 @@
                         </EllipseGeometry>
                     </Path.Data>
                 </Path>
-                <TextBlock Text="V1.1" Style="{StaticResource txtHeadStyle}" Width="60" Margin="30,0,12,0"/>
+                <TextBlock Text="V1.2" Style="{StaticResource txtHeadStyle}" Width="60" Margin="30,0,12,0"/>
             </StackPanel>
           
         </Border>