From d6f7c020e620ab4603eb0e1ee0c2222ea26494e3 Mon Sep 17 00:00:00 2001 From: denglihong2007 <2639367181@qq.com> Date: Thu, 6 Mar 2025 00:15:25 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=94=B9=E5=96=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BooleanToVisibilityConverter.cs | 19 +++++++++++++++++++ .../Simulation/ScreenSimulationPage.xaml | 13 ++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 CRSim/Converters/BooleanToVisibilityConverter.cs diff --git a/CRSim/Converters/BooleanToVisibilityConverter.cs b/CRSim/Converters/BooleanToVisibilityConverter.cs new file mode 100644 index 0000000..ae3e129 --- /dev/null +++ b/CRSim/Converters/BooleanToVisibilityConverter.cs @@ -0,0 +1,19 @@ +namespace CRSim.Converters +{ + public class BooleanToVisibilityConverter : IValueConverter + { + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is bool b) + { + return b ? Visibility.Visible : Visibility.Collapsed; + } + return null; + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/CRSim/Views/Pages/Simulation/ScreenSimulationPage.xaml b/CRSim/Views/Pages/Simulation/ScreenSimulationPage.xaml index 9176a54..568bf0f 100644 --- a/CRSim/Views/Pages/Simulation/ScreenSimulationPage.xaml +++ b/CRSim/Views/Pages/Simulation/ScreenSimulationPage.xaml @@ -3,6 +3,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:CRSim.Controls" + xmlns:converters="clr-namespace:CRSim.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" xmlns:local="clr-namespace:CRSim.Views" @@ -12,7 +13,9 @@ d:DesignWidth="800" Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - + + + @@ -104,8 +107,8 @@ - - + + @@ -124,8 +127,8 @@ - - + +