From 3feb946b47cbc6901d357b86d3e0db6bea3ef2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sun, 1 Dec 2024 21:50:14 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20issue=20=EF=BC=88#116=20=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue (#116 ) --- .../ExampleViews/BasicControlsExample.xaml | 66 ++++++++++++--- .../Core/Helpers/ElementHelper.cs | 9 ++- .../Styles/Styles.TabControl.xaml | 80 ++++++++++++++++--- 3 files changed, 132 insertions(+), 23 deletions(-) diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml index b216fc5c..fccc5e44 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/BasicControlsExample.xaml @@ -779,32 +779,67 @@ - + - + - + - + - + + + + - + - + - + @@ -812,13 +847,22 @@ Margin="4" IsEnabled="False" TabStripPlacement="Right"> - + - + - + diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs index f040e1ea..ea877d62 100644 --- a/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs +++ b/src/WPFDevelopers.Shared/Core/Helpers/ElementHelper.cs @@ -93,14 +93,17 @@ private static void ButtonClear_Click(object sender, RoutedEventArgs e) if (sender is Button button) { if (button.TemplatedParent is TextBox textBox) - { textBox.Clear(); - } else if (button.TemplatedParent is PasswordBox passwordBox) - { passwordBox.Clear(); + else if (button.TemplatedParent is TabItem tabItem) + { + var tabControl = tabItem.Parent as TabControl; + if (tabControl != null) + tabControl.Items.Remove(tabItem); } } } + } } \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Styles/Styles.TabControl.xaml b/src/WPFDevelopers.Shared/Styles/Styles.TabControl.xaml index 03820288..b0983557 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.TabControl.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.TabControl.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:WPFDevelopers.Controls" - xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"> + xmlns:helpers="clr-namespace:WPFDevelopers.Helpers" + xmlns:resx="clr-namespace:WPFDevelopers"> @@ -19,15 +20,52 @@ - + - + + + + + + + + + @@ -38,6 +76,28 @@ + + + + @@ -85,6 +145,8 @@