C# WPF开源控件库HandyControl用法举例

2023-05-16

目录

概述

MessageBox用法举例

Button用法举例

Lable用法举例

Slider用法举例

TextBox用法举例

组合框ComboBox用法举例

源码下载


 

概述

HandyControl是一款免费开源的WPF控件库,Github可以获取到源代码,相关的示例代码也在github上能获取到,但是没有详细的中文说明文档,对于新手而言使用起来还是会有一些困扰,网上也很难搜到相关的用法示例,所以本节就对它常用的一些控件举例说明下。

首先还是先在nuget上引用HC的库:

然后在前台XAML引用:

 xmlns:hc="https://handyorg.github.io/handycontrol"

在App.xaml中引用HC的皮肤和主题:

<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>

MessageBox用法举例

①对话框

MessageBox.Show("检测到有版本更新,是否更新?", "标题", MessageBoxButton.YesNo, MessageBoxImage.Question);

②提示框:

MessageBox.Show("当前选中了:" + listbox.SelectedItem, "标题", MessageBoxButton.OK, MessageBoxImage.Information);

③错误框:

MessageBox.Show("当前选中了:" + listbox.SelectedItem, "标题", MessageBoxButton.OK, MessageBoxImage.Error);

总共有9个枚举量可供选择,分别如下:​​​​​​​

//
    // 摘要:
    //     Specifies the icon that is displayed by a message box.
    public enum MessageBoxImage
    {
        //
        // 摘要:
        //     The message box contains no symbols.
        None = 0,
        //
        // 摘要:
        //     The message box contains a symbol consisting of white X in a circle with a red
        //     background.
        Error = 16,
        //
        // 摘要:
        //     The message box contains a symbol consisting of a white X in a circle with a
        //     red background.
        Hand = 16,
        //
        // 摘要:
        //     The message box contains a symbol consisting of white X in a circle with a red
        //     background.
        Stop = 16,
        //
        // 摘要:
        //     The message box contains a symbol consisting of a question mark in a circle.
        //     The question mark message icon is no longer recommended because it does not clearly
        //     represent a specific type of message and because the phrasing of a message as
        //     a question could apply to any message type. In addition, users can confuse the
        //     question mark symbol with a help information symbol. Therefore, do not use this
        //     question mark symbol in your message boxes. The system continues to support its
        //     inclusion only for backward compatibility.
        Question = 32,
        //
        // 摘要:
        //     The message box contains a symbol consisting of an exclamation point in a triangle
        //     with a yellow background.
        Exclamation = 48,
        //
        // 摘要:
        //     The message box contains a symbol consisting of an exclamation point in a triangle
        //     with a yellow background.
        Warning = 48,
        //
        // 摘要:
        //     The message box contains a symbol consisting of a lowercase letter i in a circle.
        Asterisk = 64,
        //
        // 摘要:
        //     The message box contains a symbol consisting of a lowercase letter i in a circle.
        Information = 64
    }

Button用法举例

①带图标的button:​​​​​​​

<Button Height="48" Width="160" Margin="3" Name="testBtn"
                        Background="{DynamicResource PrimaryBrush}"
                        hc:BackgroundSwitchElement.MouseHoverBackground="{DynamicResource MouseHoverBrush}" 
                        hc:BackgroundSwitchElement.MouseDownBackground="{DynamicResource MouseDownBrush}">
                        <Button.Content>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Image Source="pack://application:,,,/Images/icon.ico"/>
                                <Label Grid.Column="1" Content="Custom Button" BorderThickness="0" Background="Transparent" Foreground="{DynamicResource TextIconBrush}"/>
                            </Grid>
                        </Button.Content>
                    </Button>

②RepeatButton用法:​​​​​​​

<RepeatButton Height="48" Width="160" Content="Repeat Button" Margin="3" Delay="500" 
                      Style="{StaticResource RepeatButtonPrimary}" Background="{DynamicResource PrimaryBrush}" 
                      Foreground="{DynamicResource TextIconBrush}" hc:BorderElement.CornerRadius="5" Name="RepeatButton_Click"/>

③带有日历图表的button:​​​​​​​

 <Button  Margin="5" Style="{StaticResource ButtonPrimary}" hc:IconElement.Geometry="{StaticResource CalendarGeometry}"/>
 <Button  IsEnabled="False" Margin="5" Style="{StaticResource ButtonPrimary}" hc:IconElement.Geometry="{StaticResource CalendarGeometry}"/>

④左旋转又旋转图表button:​​​​​​​

<Button Margin="5" Style="{StaticResource ButtonSuccess}" hc:IconElement.Geometry="{StaticResource RotateLeftGeometry}"/>
<Button IsEnabled="False" Margin="5" Style="{StaticResource ButtonSuccess}" hc:IconElement.Geometry="{StaticResource RotateLeftGeometry}"/>

⑤带左右箭头图标的button:​​​​​​​

<Button Margin="5" Style="{StaticResource ButtonWarning}" hc:IconElement.Geometry="{StaticResource LeftGeometry}"/>
<Button Margin="5" Style="{StaticResource ButtonWarning}" hc:IconElement.Geometry="{StaticResource RightGeometry}"/>

⑥ToggleButton  按钮​​​​​​​

<ToggleButton IsChecked="True" Margin="5,8" HorizontalAlignment="Center" Style="{StaticResource ToggleButtonSwitch}" hc:VisualElement.HighlightBrush="{DynamicResource DangerBrush}"/>
<ToggleButton IsEnabled="False" IsChecked="True" HorizontalAlignment="Center" Margin="5,4" Style="{StaticResource ToggleButtonSwitch}"/>

Lable用法举例

<Label Content="DangerBrush" Style="{StaticResource LabelDanger}"/>
<Label Content="DarkPrimaryBrush" Background="{DynamicResource DarkPrimaryBrush}" Foreground="White" BorderThickness="0"/>

Slider用法举例

<Slider Width="400" IsSnapToTickEnabled="True" Value="8"/>
<Slider Width="400" IsSnapToTickEnabled="True" TickFrequency="5" Maximum="100" TickPlacement="TopLeft" Value="10" IsSelectionRangeEnabled="True" SelectionStart="10" SelectionEnd="80"/>
<Slider Width="400" hc:TipElement.Visibility="Visible" hc:TipElement.Placement="Top" IsSnapToTickEnabled="True" Maximum="100" Value="60" TickFrequency="10" TickPlacement="BottomRight"/>
<Slider Width="400" hc:TipElement.Visibility="Visible" hc:TipElement.Placement="Bottom" hc:TipElement.StringFormat="#0.00" Value="5" TickPlacement="Both"/>

TextBox用法举例

<TextBox Margin="0,0,0,32" hc:InfoElement.TitleWidth="70" hc:InfoElement.Placeholder="Necessary" hc:InfoElement.TitlePlacement="Left" 
                         hc:InfoElement.Title="Left title" hc:InfoElement.Necessary="True" Style="{StaticResource TextBoxExtend}" Name="TextContent"/>

组合框ComboBox用法举例​​​​​​​

<ComboBox  IsEditable="True" Width="380" hc:InfoElement.TitleWidth="140"  hc:InfoElement.TitlePlacement="Left" hc:InfoElement.Title="combox" hc:InfoElement.Necessary="True" Style="{StaticResource ComboBoxExtend}" Margin="0,16,0,0">
                    <ComboBoxItem>张三</ComboBoxItem>
                    <ComboBoxItem>李四</ComboBoxItem>
                    <ComboBoxItem>王五</ComboBoxItem>
                </ComboBox>

还有很多基本控件,限于篇幅本节就讲到这里,要想深入学习了解还是得下载源代码去探索调试.

源码下载

链接:https://pan.baidu.com/s/1Rdx43-8Aa21gl_YPsh6ncg 

提取码:6666

本文参考链接:https://github.com/HandyOrg/HandyControl 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

C# WPF开源控件库HandyControl用法举例 的相关文章

  • 使用HAL库驱动WS2812 LED的STM32F401代码示例

    使用HAL库驱动WS2812 LED的STM32F401代码示例 include 34 stm32f4xx hal h 34 include lt stdlib h gt define LED COUNT 10 TIM HandleType
  • 开源项目-esp32—S3+lvgl智能手表

    23 5 4 QF ZERO V2 V1 0 2 智能手表终端 嘉立创EDA开源硬件平台 oshwhub com 致敬大神 硬件资源 xff1a 1 xff09 ESP32 S3 为核心主控 xff0c 负责复杂的运算与交互处理 xff0c
  • nRF52832芯片使用ADC的代码示例

    nRF52832芯片使用ADC的代码示例 define ADC REF VOLTAGE IN MILLIVOLTS 600 lt Reference voltage in millivolts used by ADC while doing
  • nRF52832的I2C例程代码

    nRF52832的I2C例程代码 include 34 nrf drv i2c h 34 include 34 app error h 34 define I2C SCL PIN 0 SCL引脚号 define I2C SDA PIN 1
  • HX711 24位A/D模块计算公式

    基本原理讲解 100kg 传感器 满量程输出电压 61 激励电压 灵敏度2 0mv v 例如 xff1a 供电电压是5v 乘以灵敏度2 0mv v 61 满量程10mv 相当于有100Kg 重力产生时候产生10mV 的电压 711模块对产生
  • stm32 keil实现串口printf输出中文字符

    添加如下代码 xff0c 可以GNUC的方式实现 span class hljs comment ifdef GNUC span With GCC RAISONANCE small printf option LD Linker gt Li
  • stm32 基于TIM1定时器的PWM输出

    void PWM TIM1 uint16 t arr uint16 t psc RCC APB2PeriphClockCmd RCC APB2Periph TIM1 ENABLE 定时器TIM1时钟使能 TIM DeInit TIM1 设置
  • stm32 can总线参考例程

    CAN初始化 tsjw 重新同步跳跃时间单元 范围 1 3 CAN SJW 1tq CAN SJW 2tq CAN SJW 3tq CAN SJW 4tq tbs2 时间段2的时间单元 范围 1 8 tbs1 时间段1的时间单元 范围 1
  • 物联网IOT-mqtt协议

    MQTT是一种客户机服务器发布 订阅消息传递传输协议 它重量轻 开放 简单 设计简单 易于实现 这些特性使其非常适合在许多情况下使用 xff0c 包括受限的环境 xff0c 如机器间通信 M2M 和物联网 IoT 环境 xff0c 在这些环
  • 联合索引的最左匹配原则的成因

    联合索引的最左匹配原则的成因 上面我们只看的是单一的索引 xff0c 接下来咱们来看看联合索引 xff0c 也就是回答第二个问题 联合索引的最左匹配原则的成因 什么是联合索引呢 xff0c 就是由多列组成的索引了 那亦要了解其成因 xff0
  • 腾讯云轻量服务器的Ubuntu如何使用root(根)用户登陆ssh/Shell/terminal/终端/WindTerm/FinalShell

    Ubuntu 系统的默认用户名是 ubuntu xff0c 并在安装过程中默认不设置 root 帐户和密码 您如有需要 xff0c 可在设置中开启允许 root 用户登录 具体操作步骤如下 xff1a 使用 ubuntu 帐户登录轻量应用服
  • Ubuntu安装sshd服务

    ubuntu安装ssh服务 一 安装shhd SSH分客户端openssh client和openssh server 如果你只是想登陆别的机器的SSH只需要安装openssh client xff08 ubuntu有默认安装 xff0c
  • Linux环境(六)--资源与限制

    资源与限制 运行在Linux系统上的程序是有资源限制的 这些也许是硬件引起的限制 例如内存 xff0c 也许由系统策略引起的限制 例如 xff0c 允许 的CPU时间 xff0c 或者是实现的限制 例如 xff0c 整数的尺寸或是文件名允许
  • 遇到了C/C++控制台程序无法输入中文的情况

    其实C C 43 43 控制台程序无法cin中文的情况并不是你使用了string xff0c string是能输入并保存中文的 xff1b 经过一番探究 xff0c 我发现主要的问题是文件的编码和控制台所处的代码页 xff08 控制台的编码
  • Jpg2Dcm中文乱码问题

    Jpg2Dcm中文乱码问题 最近老板提出了一个新的功能要求 xff0c 希望可以把图片转成dcm 在实现功能的问题中遇见了很多问题和掉过许多坑 于是在此记录下来 问题 xff1a 第一次在进行Jpg2Dcm时 xff0c 可以进行图片转dc
  • 神经网络的数学表达式,神经网络的数学理论

    什么是神经网络 神经网络可以指向两种 xff0c 一个是生物神经网络 xff0c 一个是人工神经网络 生物神经网络 xff1a 一般指生物的大脑神经元 xff0c 细胞 xff0c 触点等组成的网络 xff0c 用于产生生物的意识 xff0
  • python装饰器详解(四)---把参数传递给装饰器

    因为装饰器必须接收一个函数当做参数 所以 不可以直接把被装饰函数的参数传递给装饰器 装饰器就是一个普通的函数 xff0c 回顾 def my decorator func print 34 I am an ordinary function
  • Motion Deblurring图像运动去模糊代码

    http www di ens fr whyte Efficient Deblurring for Shaken and Partially Saturated Images http www di ens fr willow resear
  • maven执行install时报错 The packaging for this project did not assign a file to the build artifact

    问题描述 maven中执行plugins下面的install install时会报如下错误 span class token class name Failed span span class token keyword to span s
  • realsense相机两种获取相机内外参的方式

    https www it610 com article 1296417297711308800 htm 命令 xff1a rs sensor control 这个命令是一个exe文件 xff0c 可以去 C Program Files x8

随机推荐

  • wget设置代理

    1 在bash shell中设定代理 basrhc export http proxy 61 34 166 111 53A 167 3128 34 export ftp proxy 61 34 166 111 53A 167 3128 34
  • chown,chgrp,chmod,u+s,g+s,o+t

    chown user file directory change owner 将后面的目标文件或者目录的所有者替换成 user chgrp group file directory change group 将目标文件或者目录的所有组替换成
  • Segment Routing笔记(一)

    SR 理论 一 MPLS TE缺点 RSVP TE大部分都是为了FRR的目的不支持ECMP所有流量都需要在隧道里诞生了 战术型 TE xff0c 只在需要的时候使用 术语 TI LFA 与拓扑无关的无环路备份 xff0c 能保证备份路径的最
  • Springboot+Netty搭建UDP服务端

    UDP是一个无连接协议 xff0c 应用范围很大 xff0c 对于一些低功耗的设备可以使用UDP方式向云端推送消息信息 xff0c 也可以在推送消息时收到从云端原路返回的消息 xff0c 使用Netty 43 SpringBoot方式可以快
  • Springboot+Netty搭建UDP客户端

    使用Netty 43 SpringBoot方式可以快速地开发一套基于UDP协议的服务端程序 xff0c 同样的也可以开发客户端 xff0c 一般使用UDP都是使用原生的方式 xff0c 发送消息后就不管不问 xff0c 也就是不需要确定消息
  • Springboot+Netty搭建MQTT协议的服务端(基础Demo)

    Netty是业界最流行的nio框架之一 xff0c 结合springboot可以满足快速开发 MQTT xff08 Message Queuing Telemetry Transport xff0c 消息队列遥测传输协议 xff09 xff
  • SpringBoot+Shiro+Jwt+Vue+elementUI实现前后端分离单体系统Demo

    记录一下使用SpringBoot集成Shiro框架和Jwt框架实现前后端分离Web项目的过程 xff0c 后端使用SpringBoot整合Shiro 43 Jwt auth0 xff0c 前端使用vue 43 elementUI框架 xff
  • Centos系统安装RabbitMQ消息中间件

    记录一下在centos7 x下面安装RabbitMQ消息中间件 RabbitMQ是一个开源而且遵循 AMQP协议实现的基于 Erlang语言编写 xff0c 因此安装RabbitMQ之前是需要部署安装Erlang环境的 先安装Erlang
  • SpringBoot+RXTXcomm实现Java串口通信 读取串口数据以及发送数据

    记录一下使用SpringBoot 43 RXTXcomm实现Java串口通信 xff0c 使用Java语言开发串口 xff0c 对串口进行读写操作 RXTXcomm jar这个包支持的系统较多 xff0c 但是更新太慢 xff0c 在win
  • Springboot+Netty搭建TCP服务端

    Netty是业界最流行的nio框架之一 xff0c 它具有功能强大 性能优异 可定制性和可扩展性的优点 Netty的优点 xff1a 1 API使用简单 xff0c 开发入门门槛低 2 功能十分强大 xff0c 预置多种编码解码功能 xff
  • Springboot+Netty搭建TCP客户端-多客户端

    之前搭建了一个Springboot 43 Netty服务端的应用 xff0c 既然有服务端 xff0c 自然也有客户端的应用 xff0c 现在搭建一个Springboot 43 Netty客户端的应用Demo程序 xff0c 多客户端方式
  • 机器学习中的凸和非凸优化问题

    题目 xff08 145 xff09 xff1a 机器学习中的优化问题 xff0c 哪些是凸优化问题 xff0c 哪些是非凸优化问题 xff1f 请各举一个例子 凸优化定义 凸优化问题 非凸优化问题 凸优化定义 xff1a 公式 geome
  • VMware workstation中rhel安装VMware tools失败

    切换登录用户为root即可 转载于 https www cnblogs com dazzleC p 10555809 html
  • Uniform convergence may be unable to explain generalization in deep learning

    本文价值 xff1a understand the limitations of u c based bounds cast doubt on the power of u c bounds to fully explain general
  • 调参之learning rate

    The learning rate is perhaps the most important hyperparameter If you have time to tune only one hyperparameter tune the
  • 调超参(lr,regularization parameter)经验整理

    Learning rate 最优值从1e 4到1e 1的数量级都碰到过 xff0c 原则大概是越简单的模型的learning rate可以越大一些 https blog csdn net weixin 44070747 article de
  • Dropout network, DropConnect network

    Notations input v v v output r r r weight parameter
  • Curriculum adversarial training

    Weakness of adversarial training overfit to the attack in use and hence does not generalize to test data Curriculum adve
  • Python处理中文语言——读取中文

    本文解决问题 xff1a 1 导入中文txt文本 xff0c 并转换为unicode 2 导入包含中文的py file 解决问题一 xff1a 导入中文txt文本 xff0c 并转换为unicode 基础概念 xff1a 1 unicode
  • C# WPF开源控件库HandyControl用法举例

    目录 概述 MessageBox用法举例 Button用法举例 Lable用法举例 Slider用法举例 TextBox用法举例 组合框ComboBox用法举例 源码下载 概述 HandyControl是一款免费开源的WPF控件库 xff0