LeeTeke.WpfHelper 0.0.3-dev

This is a prerelease version of LeeTeke.WpfHelper.
dotnet add package LeeTeke.WpfHelper --version 0.0.3-dev
                    
NuGet\Install-Package LeeTeke.WpfHelper -Version 0.0.3-dev
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LeeTeke.WpfHelper" Version="0.0.3-dev" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LeeTeke.WpfHelper" Version="0.0.3-dev" />
                    
Directory.Packages.props
<PackageReference Include="LeeTeke.WpfHelper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LeeTeke.WpfHelper --version 0.0.3-dev
                    
#r "nuget: LeeTeke.WpfHelper, 0.0.3-dev"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LeeTeke.WpfHelper@0.0.3-dev
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LeeTeke.WpfHelper&version=0.0.3-dev&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=LeeTeke.WpfHelper&version=0.0.3-dev&prerelease
                    
Install as a Cake Tool

LeeTeke.WpfHelper

一款WPF辅助方法工具,不包含任何控件,包含如下功能:

  • 系统主题与主题色相关管理
  • 颜色相关功能管理
  • 动画辅助功能
  • 多个转换器

Nuget

NUGET

dotnet add package LeeTeke.WpfHelper

使用

在xaml中


  xmlns:lw="https://github.com/leeteke/LeeTeke.WpfHelper"

在C#中引用

using LeeTeke.WpfHelper;

介绍

系统主题与主题色相关管理

相关类名 : LeeTeke.WpfHelper.AppThemeHelper
名称 类别 介绍
SystemTheme 属性(只读) 系统主题模式(Light/Dark)
SystemBrush 属性(只读) 系统主题色
SystemColor 属性(只读) 系统主题色
CurrentTheme 属性(只读) 当前的主题模式
IsCustomTheme 属性(只读) 是否是自定义主题模式
CurrentColor 属性(只读) 当前的主题颜色
AppThemeChanged 事件 当主题模式发生改变时
AppColorChanged 事件 当主题颜色发生改变时
SetCustomThemeMode 方法 设置自定义主题模式,当为空时则代表设置跟随系统
SetCustomThemeColor 方法 设置自定义主题颜色,当为空时则代表设置跟随系统
在XAML中可搭配 AppThemeBinding 使用,用来控制Light/Dark不同的属性值。(默认是Light)
<Window
    ......
    xmlns:lw="https://github.com/leeteke/LeeTeke.WpfHelper"
   >
    <Window.Resources>
        <SolidColorBrush x:Key="LightBrush" Color="#F0F0F0" />
        <SolidColorBrush x:Key="DarkBrush" Color="#050505" />
    </Window.Resources>
    <Grid Background="{lw:AppThemeBinding Light={StaticResource LightBrush}, Dark={StaticResource DarkBrush}}">
        <Grid.Resources>
            <Style x:Key="A" TargetType="{x:Type Rectangle}">
                <Setter Property="Width" Value="100" />
                <Setter Property="Height" Value="100" />
                <Setter Property="Fill" Value="{StaticResource LightBrush}" />
            </Style>
            <Style x:Key="B" TargetType="{x:Type Rectangle}">
                <Setter Property="Width" Value="100" />
                <Setter Property="Height" Value="200" />
                <Setter Property="Fill" Value="{StaticResource DarkBrush}" />
            </Style>
        </Grid.Resources>

        <StackPanel VerticalAlignment="Top" Orientation="Horizontal">
            <TextBlock Foreground="{lw:AppThemeBinding Light=Black, Dark=White}">
                <Run>当前主题为:</Run>
                <Run Text="{lw:AppThemeBinding Dark=暗黑, Light=明亮}" />
            </TextBlock>
           
        </StackPanel>
        <Rectangle Style="{lw:AppThemeBinding Dark={StaticResource A}, Light={StaticResource B}}" />
    </Grid>
</Window>


在C#中可直接使用 AppThemeBinding 来构建绑定
     tbManualBinding.SetBinding(TextBlock.TextProperty, new AppThemeBinding("这是手动绑定的,在Light模式下显示。", "这是手动绑定的,在Dark模式下出现。"));

动画辅助方法

详情见代码

颜色相关方法

详情见代码

多个转换器

名称 介绍 参数
BrushDepthConverter 画刷深浅转换器 float:正数代表加深负数代表减轻,取值范围-1f~1f
ColorDepthConverter 画刷深浅转换器 double:正数代表加深负数代表减轻,取值范围-1f~1f
BrushOpacityConverter 画刷透明度换器 float:正数代表加深负数代表减轻,取值范围-1f~1f
ColorOpacityConverter 颜色透明度转换器 double:正数代表加深负数代表减轻,取值范围-1f~1f
BrushContrastConverter 取画刷所对应的黑白对比色 可选参数,参数格式为:#000000/#FFFFFF ,使用 ‘/’进行分割,前面的参数为深色参数,后面的为浅色参数。无则默认深色参数为黑色,浅色参数为白色
ColorContrastConverter 取颜色所对应的黑白对比色 可选参数,参数格式为:#000000/#FFFFFF ,使用 ‘/’进行分割,前面的参数为深色参数,后面的为浅色参数。无则默认深色参数为黑色,浅色参数为白色
DoubleComparisonConverter 数值比较转换器 格式为:[eum]_[num],num所比较的数值,eum有Less、LessEqual、Greater、GreaterEqual、Equal、NotEqual,可用首字母简写(L、LE、G、GE、E、NE )
DoubleFollowConverter 数值跟随转换器 格式为:[num],带符号的+-或者使用*代表乘,/代表初,例如+1、-1、*2、/2
ThemeBindingConverter 内部使用 =.=
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net5.0-windows7.0 is compatible.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows7.0 is compatible.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net10.0-windows7.0 is compatible. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net45 is compatible.  net451 is compatible.  net452 is compatible.  net46 is compatible.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 is compatible.  net471 is compatible.  net472 is compatible.  net48 is compatible.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.5.2

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.7.1

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETFramework 4.8.1

    • No dependencies.
  • net10.0-windows7.0

    • No dependencies.
  • net5.0-windows7.0

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net7.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.
  • net9.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3-dev 79 8/26/2026
0.0.2-dev 86 8/26/2026
0.0.1-dev 84 8/11/2026