iNKORE.UI.WPF.Modern试用笔记

源码地址:https://github.com/iNKORE-Public/UI.WPF.Modern
官方文档:https://docs.inkore.net/en-us/ui-wpf-modern/onboarding/

目前官方的文档不是很齐全,貌似有不少的控件的内容还是空的,还在补充中。

开发库本身同时支持.NET FRAMEWORK和.NET CORE。
但.NET CORE版本估计用到了特定版本系统的一个UI效果,所以使用.NET 8等版本的时候,需要把目标操作系统改成10.0.18362.0,不然的话会报错。
这块也可以直接看一下官方的文档。

安装

Install-Package iNKORE.UI.WPF.Modern

资源的引用

命令空间的引用:

xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"

App.xaml示例

<Application x:Class="StarterKit.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:StarterKit" 
             xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ui:ThemeResources/>
                <ui:XamlControlsResources/>
            </ResourceDictionary.MergedDictionaries>
            
            <!--Your other resources here (if exists)-->
            
        </ResourceDictionary>
    </Application.Resources>
</Application>

窗体样式的应用

命名空间:

xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"

在窗体的代码上添加下面的属性应用样式:

ui:WindowHelper.UseModernWindowStyle="True"

添加下面的属性来设置背景的样式:

ui:WindowHelper.SystemBackdropType="Mica"

窗体的示例代码:

<Window x:Class="StarterKit.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:StarterKit" 
        xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
        xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
        ui:WindowHelper.UseModernWindowStyle="True"
        ui:WindowHelper.SystemBackdropType="Mica"
        ui:TitleBar.Height="36"
        mc:Ignorable="d"
        Title="Welcome!" Height="450" Width="800">
    
    <!--I added something here, you can add whatever you want-->
    <ikw:SimpleStackPanel VerticalAlignment="Center" Spacing="5">
        <TextBlock Text="Fluent Design is beautiful." FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
        <TextBlock Text="But hey, we deserve it :-)" FontSize="20" TextAlignment="Center"/>

        <Button Content="Hello world!" HorizontalAlignment="Center" Margin="0,20,0,0"/>
    </ikw:SimpleStackPanel>
</Window>

样式的改动比较大。部分主题样式,有点半透明和毛玻璃的效果。

但是整体使用下来,遇到的问题还是比较多。

估计一些控件在重做样式的过程中,内部指定了字体等信息,所以窗体层面和外部的字体和字体大小失效了。

而且主题控件内部可能直接用了一些库。导致prism:InvokeCommandAction不能使用。
并且像一些封装好的Behavior类也不能使用了。

<i:Interaction.Behaviors>
    <cg:DataGridSelectedItemsBehavior SelectedItems="{Binding SelectedItems}" />
</i:Interaction.Behaviors>

因为文档和官方的示例并不全,所以包括很多样式的修改这些都不是特别清楚。

posted @   wzwyc  阅读(250)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
历史上的今天:
2021-12-03 关于PropertyChanged.Fody的使用
点击右上角即可分享
微信分享提示