原文:https://github.com/benruehl/adonis-ui
The Wolf at the End of the Desert
Lightweight UI toolkit for WPF applications that provides classic and enhanced Windows visuals:

warehouse information

What is the content?
- Default styles and templates for almost all WPF controls
- Other styles that can be used as needed for ease of use
- Two color schemes (light and dark) can also be used to customize styles
- Supports changing color schemes at run time
- Support for other custom color schemes
- Extension of built-in controls to provide watermarks and other functions
- There are few custom controls for common use cases
design principles
- Maintain close to the original appearance of WPF
- No configuration is required, but provides options for people who want to control global and personal behavior
- Supports WPF's extension of built-in controls to create new controls to become a direct replacement for existing applications
document
使用文档地址:https://benruehl.github.io/adonis-ui/docs/getting-started/introduction/
start
Install-Package AdonisUI.ClassicTheme -Version 1.17.1
- 像这样将资源添加到您的应用程序
App.xaml中:
<Application xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/AdonisUI;component/ColorSchemes/Light.xaml"/>
<ResourceDictionary Source="pack://application:,,,/AdonisUI.ClassicTheme;component/Resources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
- The window styles are derived from the default styles of Adonis UI, as follows:
<Window.Style>
<Style TargetType="Window" BasedOn="{StaticResource {x:Type Window}}"/>
</Window.Style>
Control features
Switch color schemes at run time
Adonis UI comes in light and dark color schemes. Custom color schemes can be added without restrictions.
| Light color scheme | Dark scheme Scheme |
|---|---|
![]() |
![]() |
要在运行时切换配色方案,ResourceDictionary需要从应用程序资源中删除包含方案的所有颜色和画笔,以便可以添加不同的配色方案。这可以使用内置ResourceLocator类来完成,例如在单击事件处理程序中。
AdonisUI.ResourceLocator.SetColorScheme(Application.Current.Resources, ResourceLocator.DarkColorScheme);
第一个参数必须是对 ResourceDictionary 包含配色方案的引用,作为其MergedDictionaries。 第二个参数是应添加的配色方案的 Uri。
accent color
While relying on a uniform color for the background area and border, accent colors can be used to visually highlight important points. By default, both color schemes use blue as the accent color. This can be changed by overriding the accent color value. A set of styles helps display controls such as buttons in accent colors.
Customize window title bar
Adonis UI 带来了一个自定义窗口标题栏,默认情况下看起来与 Windows 10 标题栏一模一样,但有几个优点。首先,它尊重当前的配色方案,因此在切换到深色配色方案时它会变暗。其次,它的颜色也可以独立于颜色方案设置,例如通过绑定和触发器。第三,它的内容可以很容易地定制,例如通过隐藏图标、添加额外的按钮或在其中放置标签。派生您的窗口AdonisWindow以接收这些功能。
![]() |
![]() |
![]() |
![]() |
Cursor Spotlight hover effect
依赖交互的 UI 控件(如按钮、文本框、组合框、列表框等)在此处使用称为 Cursor Spotlight 的悬停效果。当将鼠标悬停在隐藏的控件上时,它会使光标周围的图层可见。它适用于两种配色方案。
| Light color scheme | Dark scheme Scheme |
|---|---|
![]() |
![]() |
因为它与OpacityMasks一起作用不仅限于照亮 UI 控件。它可以用来隐藏几乎所有可以用 WPF 渲染的东西。
Chain reaction (Ripple effect)
By default, buttons and ContextMenuItems display a ripple effect when clicked. ListBoxItems also supports it, but disables it by default.
| Light color scheme | Dark scheme Scheme |
|---|---|
![]() |
![]() |
layer
In UI design, it is common for containers to group items that belong together. For example, in WPF, this can be easily achieved using Group Boxes. If the container is assigned a different background color to better distinguish grouped items and their surroundings, color contrast can become a problem. Gray buttons may initially look good on a white application background, but when they are moved into GroupBox, which also has a gray background, they may lose visibility.
That's why Adonis UI introduces a simple hierarchical system that automatically adjusts the color of UI controls based on the layer to which they belong. By default, all styles of Adonis UI automatically adapt to the system, but it can also be disabled.
| Light color scheme | Dark scheme Scheme |
|---|---|
![]() |
![]() |
These images show a simple layout consisting of Buttons and Group Boxes. All controls use their default styles and have no properties set except their content. The hierarchical system is responsible for slightly adjusting the color of each layer of buttons and the background of GroupBoxes. It ensures that there is always a difference between the background of the container and the background of the controls in the container. Without the system, all buttons would have exactly the same background color.
The system is fully customizable. Of course, it applies to all controls, not just buttons. Each control can be configured to add layers to its children, but it is already enabled by default for some controls, such as GroupBoxes. Controls can also be forced to reside on specific layers.
Data verification support
WPF 的数据验证机制提供了验证属性值并在它们无效时分配错误消息的能力。在 Adonis UI 中,如果控件绑定到无效属性,则错误会在控件模板中由红色边框和错误图标指示。当控件获得键盘焦点或用户将鼠标悬停在图标上时,错误消息将显示为弹出窗口。要设置验证错误,可以使用接口IDataErrorInfo或WPF。
| Light color scheme | Dark scheme Scheme |
|---|---|
![]() |
![]() |
By default, error message pop-ups appear at keyboard focus and over mouse hover. Both can be disabled individually.
ComponentResourceKeys
Adonis UI 提供的资源具有分配的 ComponentResourceKey,以便以简单的方式使用它们。资源存在于颜色、画笔、尺寸、样式、模板和图标等类别中。例如,当前配色方案的前景画笔可以通过引用其资源键来使用,如Foreground="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}"。 ComponentResourceKeys 允许使用 IntelliSense 自动完成,这在探索可用资源时会派上用场。
Space
控件之间的 Space 通常由边距、填充和网格行和列控制。为了确保每个位置的 Space 一致,可以选择一个固定的大小,在任何地方都使用(或它的倍数)。Adonis UI 提供了一个支持您这样做的系统。默认情况下,空间的基值为8,但可以分别针对水平和垂直空间进行调整。
You can apply space like this:
<RowDefinition Height="{adonisUi:Space 1}"/> <!-- equals Height="8" -->
<RowDefinition Height="{adonisUi:Space 2.5}"/> <!-- equals Height="20" -->
<RowDefinition Height="{adonisUi:Space 2.5+1}"/> <!-- equals Height="21" -->
<RowDefinition Height="{adonisUi:Space 2.5-1}"/> <!-- equals Height="19" -->
The same applies to thicknesses such as margins and padding:
<Button Margin="{adonisUi:Space 1}"/> <!-- equals Margin="8,8,8,8" -->
<Button Margin="{adonisUi:Space 1, 2}"/> <!-- equals Margin="8,16,8,16" -->
<Button Margin="{adonisUi:Space 1, 1+2, 2, 3}"/> <!-- equals Margin="8,10,16,24" -->
demo
There is a WPF presentation application on the board that displays most of the features of Adonis UI. Please don't hesitate to give it a try.
License
MIT © Benjamin Rühl













