WPF使用HandyControl(HandyOrg)框架的安装及配置

一、安装

通过NuGet包管理器搜索HandyControl并安装

二、配置

在App.xaml配置资源(合并资源字典)

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

三、使用附加属性

方式1、给指定控件附加属性

        <Button x:Name="but1" Width="150" Height="100" HorizontalAlignment="Center">
            <Button.Style>
                <Style TargetType="{x:Type Button}">
                    <Setter Property="Background" Value="Red"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border Background="{TemplateBinding Background}" BorderBrush="Black" BorderThickness="1">
                                    <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{Binding Path=(hc:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>

方式2、资源里添加一个属性模板 

    <Window.Resources>
        <ControlTemplate TargetType="{x:Type Button}" x:Key="ButtonTem">
            <Border Background="{TemplateBinding Background}" Name="btnBord" BorderBrush="Black" BorderThickness="1">
                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" TargetName="btnBord" Value="{Binding Path=(hc:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="red"  TargetName="btnBord"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>
    <Grid>
        <Button x:Name="but1" Width="150" Height="100" Background="Green" Template="{StaticResource ButtonTem}"/>
    </Grid>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
近年来,随着WPFWindows Presentation Foundation)技术的发展,越来越多的项目开始采用WPF作为前端开发框架。而在WPF开发中,HandyControl是非常受欢迎的一种UI控件库。 HandyControl提供了丰富的可重用控件和组件,可以帮助开发人员更轻松地构建各种复杂的界面。下面是一个使用HandyControl的项目案例。 假设一个团队正在开发一个任务管理系统,用于管理团队成员的任务分配和进度跟踪。在这个项目中,使用WPF作为前端框架,并集成了HandyControl以实现更友好的用户界面。 在这个项目中,HandyControl提供了丰富的UI控件,包括按钮、文本框、列表框等等,这些控件可以被用来构建任务管理系统的各个界面组件。 首先,任务管理系统的主界面采用了HandyControl的导航栏控件,可以方便地切换到不同的页面,如任务列表、个人任务、团队任务等等。导航栏控件的样式和交互效果可以通过HandyControl库提供的默认样式进行定制。 在任务列表界面,使用HandyControl的数据表格控件,可以展示团队成员的任务列表,并提供筛选、排序、分页等功能,使得团队成员可以更方便地查看和管理任务。 在个人任务界面,使用HandyControl的日期选择器控件和进度条控件,可以方便地选择任务的截止日期,并实时展示任务的完成进度。 此外,还可以使用HandyControl的消息提示控件,在任务完成、新任务分配等关键事件发生时,及时通知团队成员。 总结起来,使用HandyControl可以大大简化WPF项目的开发工作,提供了丰富实用的UI控件和组件,帮助开发人员构建出高质量、易用的用户界面,提升了项目的开发效率和用户体验。通过上述案例,我们可以看到使用HandyControlWPF项目在任务管理系统中发挥了很大作用,并为团队成员提供了一个方便、高效的工作平台。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值