update doc
No files matched your search
@@ -3,40 +3,50 @@ title: BackgroundSwitchElement 可切换背景的元素
|
||||
---
|
||||
|
||||
# 准备工作
|
||||
|
||||
添加`HandyControl`命名空间
|
||||
{% code %}
|
||||
|
||||
```xml
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
{% endcode %}
|
||||
```
|
||||
|
||||
## MouseHoverBackground `鼠标悬浮背景色`
|
||||
# 相关属性
|
||||
|
||||
该附加属性常用于设置控件在鼠标悬浮时的背景色,在控件的样式或者模板中我们添加如下的触发器代码:
|
||||
| 名称 | 用途 |
|
||||
|-|-|
|
||||
| MouseHoverBackground | 设置鼠标悬浮背景色 |
|
||||
| MouseDownBackground | 设置鼠标按下背景色 |
|
||||
|
||||
{% code %}
|
||||
# 使用案例
|
||||
|
||||
## MouseHoverBackground 设置鼠标悬浮背景色
|
||||
|
||||
在样式或模板中我们添加如下的触发器代码:
|
||||
|
||||
```xml
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="Chrome" Value="{Binding Path=(hc:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
{% endcode %}
|
||||
```
|
||||
|
||||
随后我们就可以使用该属性了:
|
||||
前台使用方式:
|
||||
|
||||
{% code %}
|
||||
```xml
|
||||
<目标控件 hc:BackgroundSwitchElement.MouseHoverBackground ="Blue"/>
|
||||
{% endcode %}
|
||||
```
|
||||
|
||||
## MouseDownBackground `鼠标按下背景色`
|
||||
## MouseDownBackground 设置鼠标按下背景色
|
||||
|
||||
该附加属性常用于设置控件在鼠标按下时的背景色,在控件的样式或者模板中我们添加如下的触发器代码:
|
||||
在样式或模板中我们添加如下的触发器代码:
|
||||
|
||||
{% code %}
|
||||
```xml
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter Property="Background" TargetName="Chrome"
|
||||
Value="{Binding Path=(hc:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
<Setter Property="Background" TargetName="Chrome" Value="{Binding Path=(hc:BackgroundSwitchElement.MouseDownBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
|
||||
</Trigger>
|
||||
{% endcode %}
|
||||
```
|
||||
|
||||
随后我们就可以使用该属性了:
|
||||
前台使用方式:
|
||||
|
||||
{% code %}
|
||||
```xml
|
||||
<目标控件 hc:BackgroundSwitchElement.MouseDownBackground ="Yellow"/>
|
||||
{% endcode %}
|
||||
```
|
||||
@@ -1,47 +1,49 @@
|
||||
---
|
||||
title: 具有边框的元素
|
||||
title: BorderElement 具有边框的元素
|
||||
---
|
||||
|
||||
# 准备工作
|
||||
|
||||
使用该系附加属性的`.xaml`文件中,需要添加`HandyControl`命名空间
|
||||
{% code %}
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
{% endcode %}
|
||||
添加`HandyControl`命名空间
|
||||
|
||||
```xml
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
```
|
||||
|
||||
# 相关属性
|
||||
|
||||
| 名称 | 用途 |
|
||||
| ------------ | ---------------------------------- |
|
||||
| CornerRadius | 设置边框圆角值 |
|
||||
| Circular | 是否呈现为圆形 True为是、False为否 |
|
||||
| 名称 | 用途 |
|
||||
|-|-|
|
||||
| CornerRadius | 设置边框圆角值 |
|
||||
| Circular | 是否呈现为圆形 True为是、False为否 |
|
||||
|
||||
# 使用案例
|
||||
|
||||
## CornerRadius
|
||||
设置边框的圆角值
|
||||
## CornerRadius 设置边框圆角值
|
||||
|
||||
```xml
|
||||
<Button Content="[Button]测试CornerRadius" hc:BorderElement.CornerRadius="0"></Button>
|
||||
<hc:TextBox Text="[hc:TextBox]测试CornerRadius" hc:BorderElement.CornerRadius="15"></hc:TextBox>
|
||||
<TextBox Text="[TextBox]测试CornerRadius" hc:BorderElement.CornerRadius="0"></TextBox>
|
||||
<Button Content="[Button]测试CornerRadius" hc:BorderElement.CornerRadius="0,0,4,4"></Button>
|
||||
```
|
||||
**效果图如下:**
|
||||
|
||||

|
||||
## Circular
|
||||

|
||||
|
||||
## Circular 是否呈现为圆形
|
||||
|
||||
借助`BorderElement.Circular`附加属性实现圆形Border
|
||||
```xml
|
||||
<Border Style="{StaticResource BorderCircular}" Background="OrangeRed" Width="100" Height="100"/>
|
||||
```
|
||||
**效果如下:**
|
||||

|
||||

|
||||
|
||||
# 温馨提示
|
||||
|
||||
## 常见控件支持项
|
||||
|
||||
**所属** 是指该控件为`WPF默认`控件还是为`HandControl自定义`实现的控件
|
||||
**适用属性 ** 为当前控件`borderElement`对应有效的附加属性
|
||||
**适用属性 ** 为当前控件`BorderElement`对应有效的附加属性
|
||||
|
||||
| 控件类型 | 所属 | 适用属性 |
|
||||
| -------- | --------------------- | ------------ |
|
||||
|
||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
@@ -4,6 +4,6 @@ title: 附加属性
|
||||
|
||||
附加属性源码在Controls / Attach文件夹中:
|
||||
|
||||

|
||||

|
||||
|
||||
以`Element`结尾的类,可以为所有的控件设置一些共有的属性,以`Attach`结尾的类,只能为一种控件设置相关的属性。
|
||||
@@ -22,13 +22,21 @@ title: 转换器
|
||||
|
||||
该转换器会将布尔数组转换为`Visibility`,当数组内全部为`true`时,返回`Visible`,否则返回`Collapse`。
|
||||
|
||||
# BorderCircularClipConverter
|
||||
|
||||
该转换器为Border专用,接受一个object数组,该数组长度为3,分别对应Border的长、宽和圆角半径,它会返回一个圆形几何形状作为Clip来剪裁Border。
|
||||
|
||||
# BorderCircularConverter
|
||||
|
||||
该转换器为Border专用,接受`Border`的长和宽合成的一个整型数组,返回它们中最小值的一半,作为圆形Border的半径。
|
||||
|
||||
# BorderClipConverter
|
||||
|
||||
该转换器为Border专用,接受一个object数组,该数组长度为3,分别对应Border的长、宽和圆角半径,它会返回一个圆形几何形状作为Clip来剪裁Border。
|
||||
该转换器为Border专用,接受一个object数组,该数组长度为3,分别对应Border的长、宽和圆角半径,它会返回一个圆角矩形作为Clip来剪裁Border。
|
||||
|
||||
# ColLayoutConverter
|
||||
|
||||
该转换器用于xaml设计时,主要功能是将字符串转换为有效的`ColLayout`值。
|
||||
|
||||
# Color2ChannelAConverter(内部使用)
|
||||
|
||||
@@ -38,6 +46,10 @@ title: 转换器
|
||||
|
||||
该转换器会将`SolidColorBrush`转换为16进制字符串形式(带“#”)。
|
||||
|
||||
# CornerRadiusSplitConverter
|
||||
|
||||
该转换器需要提供一个字符串作为参数,该字符串的一般形式为:`[0/1],[0/1],[0/1],[0/1]`,4个以逗号分隔的值分别对应`CornerRadius`的`Left`、`Top`,`Right`,`Bottom`属性,当值为1则返回对应属性的值,否则返回0。
|
||||
|
||||
# Int2StrConverter
|
||||
|
||||
该转换器需要提供一个字符串作为参数,该字符串的一般形式为:`[字符串0];[字符串1];...[字符串n]`,转换器会将一个整型的值作为索引,来获取指定位置的字符串并返回。
|
||||
@@ -46,6 +58,10 @@ title: 转换器
|
||||
|
||||
该转换器会将长整型转换为文件大小的字符串。
|
||||
|
||||
# Number2PercentageConverter
|
||||
|
||||
该转换器接受一个长度为2的数字数组,返回两数的百分比值。
|
||||
|
||||
# Object2BooleanConverter
|
||||
|
||||
如果该转换器获取到的值为`null`则返回`false`,否则返回`true`。
|
||||
@@ -54,6 +70,10 @@ title: 转换器
|
||||
|
||||
如果该转换器获取到的值为`null`则返回`Collapsed`,否则返回`Visible`。
|
||||
|
||||
# RectangleCircularConverter
|
||||
|
||||
该转换器为Rectangle专用,接受`Rectangle`的长和宽合成的一个整型数组,返回它们中最小值的一半,作为圆形Rectangle的半径。
|
||||
|
||||
# String2VisibilityConverter
|
||||
|
||||
该转换器接受一个字符串,如果该字符串为空或者为null,则返回`Collapse`,否则返回`Visible`。
|
||||
@@ -62,6 +82,10 @@ title: 转换器
|
||||
|
||||
该转换器情况与`String2VisibilityConverter`相反。
|
||||
|
||||
# ThicknessSplitConverter
|
||||
|
||||
该转换器需要提供一个字符串作为参数,该字符串的一般形式为:`[0/1],[0/1],[0/1],[0/1]`,4个以逗号分隔的值分别对应`Thickness`的`Left`、`Top`,`Right`,`Bottom`属性,当值为1则返回对应属性的值,否则返回0。
|
||||
|
||||
# TreeViewItemMarginConverter(内部使用)
|
||||
|
||||
该转换器用于为TreeViewItem提供适当的左边距。
|
||||
|
||||
|
Before Width: | Height: | Size: 5.2 KiB |
@@ -3,7 +3,7 @@ title: 基础xaml定义
|
||||
---
|
||||
|
||||
基础xaml定义都在Basic文件夹中,其内部结构如下:
|
||||

|
||||

|
||||
|
||||
对它们的描述如下表所示:
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ title: Growl 信息通知
|
||||
|
||||
# 控件效果
|
||||
|
||||

|
||||

|
||||
|
||||
# 准备工作
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -2,17 +2,11 @@
|
||||
title: 欢迎使用HandyControl
|
||||
---
|
||||
|
||||
HandyControl是一套WPF控件库,它几乎重写了所有原生样式,同时包含50多款额外的控件(正逐步增加)。
|
||||
HandyControl是一套WPF控件库,它几乎重写了所有原生样式,同时包含60余款自定义控件(正逐步增加)。
|
||||
|
||||
# 要求
|
||||
|
||||
- 使用要求
|
||||
.Net >= 4.0
|
||||
OS >= win7
|
||||
|
||||
- 编译要求
|
||||
IDE >= vs2019
|
||||
C# >= 7.3
|
||||
   
|
||||
|
||||
# 下载
|
||||
|
||||
@@ -39,7 +33,7 @@ Github上一般每天都有更新,相对而言不适合用于生产。
|
||||
## 整体结构
|
||||
|
||||
从Github上克隆好源码后,进入src文件夹,该文件夹结构如下:
|
||||

|
||||

|
||||
|
||||
这里一共有4个解决方案sln文件。
|
||||
|
||||
@@ -48,14 +42,14 @@ Github上一般每天都有更新,相对而言不适合用于生产。
|
||||
`Shared`文件夹用于存放共享项目的代码
|
||||
|
||||
图中五个文件夹内部各包含两个子文件夹,例如在Shared中还包含两个子文件夹:
|
||||

|
||||

|
||||
|
||||
它们分别存放控件源码和控件示例源码。
|
||||
|
||||
## 源码结构
|
||||
|
||||
我们以HandyControl_Net_GE45.sln为示例进行说明,使用VS2017打开该解决方案:
|
||||

|
||||
我们以HandyControl.sln为示例进行说明,使用VS2019打开该解决方案:
|
||||

|
||||
|
||||
如果要启动示例,查看控件效果,请将HandyControlDemo_[指定的项目类型]作为启动项。
|
||||
|
||||
@@ -82,7 +76,7 @@ Controls中的每个控件一般都能在Themes中找到对应的xaml定义。
|
||||
# 编译源码
|
||||
|
||||
{% note warning %}
|
||||
编译前请确认你的开发环境是否符合使用要求。
|
||||
编译前请确认你的开发环境是否符合要求。
|
||||
{% endnote %}
|
||||
|
||||
{% note info %}
|
||||
|
||||
@@ -6,7 +6,7 @@ title: Border 边框
|
||||
|
||||
此样式用于包裹一个控件区域,配合基础xaml定义中的几个DropShadowEffect资源可制作如下效果:
|
||||
|
||||

|
||||

|
||||
|
||||
以上效果的xaml代码如下:
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@ title: Calendar 日历
|
||||
{% code %}
|
||||
<Calendar/>
|
||||
{% endcode %}
|
||||

|
||||

|
||||
{% endnote %}
|
||||
@@ -19,5 +19,5 @@ title: CheckBox 复选框
|
||||
<CheckBox Margin="0,16,0,0" Content="CheckBox" IsChecked="{x:Null}" IsEnabled="False"/>
|
||||
</StackPanel>
|
||||
{% endcode %}
|
||||

|
||||

|
||||
{% endnote %}
|
||||
@@ -18,5 +18,5 @@ title: ContextMenu 上下文菜单
|
||||
</ContextMenu.ItemTemplate>
|
||||
</ContextMenu>
|
||||
{% endcode %}
|
||||

|
||||

|
||||
{% endnote %}
|
||||
@@ -41,7 +41,7 @@ title: DataGrid 数据表格
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
{% endcode %}
|
||||

|
||||

|
||||
{% endnote %}
|
||||
|
||||
# FAQ
|
||||
|
||||
@@ -4,15 +4,11 @@ title: 鸣谢
|
||||
|
||||
# 感谢以下Coder提供代码贡献
|
||||
|
||||
<p><a style="border:0" href="https://github.com/ghost1372" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/9213496?s=400&v=4" alt="ghost1372"></a><a style="border:0" href="https://github.com/DingpingZhang" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/8541016?s=400&v=4" alt="Dingping Zhang"></a><a style="border:0" href="https://github.com/M0n7y5" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/17201053?s=400&v=4" alt="M0n7y5"></a><a style="border:0" href="https://github.com/guanguanchuangyu" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars1.githubusercontent.com/u/25916858?s=400&v=4" alt="guanguanchuangyu"></a><a style="border:0" href="https://github.com/yanchao891012" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/16846702?s=400&v=4" alt="yanchao891012"></a><a style="border:0" href="https://github.com/noctwolf" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars3.githubusercontent.com/u/21022467?s=400&v=4" alt="noctwolf"></a></p>
|
||||
|
||||
# 感谢以下User提供使用建议
|
||||
|
||||
<p><a style="border:0" href="https://github.com/xianyun666" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars1.githubusercontent.com/u/22339210?s=400&v=4" alt="xianyun666"></a></p>
|
||||
<p><a style="border:0" href="https://github.com/ghost1372" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/9213496?s=400&v=4" alt="ghost1372"></a><a style="border:0" href="https://github.com/DingpingZhang" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/8541016?s=400&v=4" alt="Dingping Zhang"></a><a style="border:0" href="https://github.com/M0n7y5" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/17201053?s=400&v=4" alt="M0n7y5"></a><a style="border:0" href="https://github.com/guanguanchuangyu" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars1.githubusercontent.com/u/25916858?s=400&v=4" alt="guanguanchuangyu"></a><a style="border:0" href="https://github.com/yanchao891012" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars0.githubusercontent.com/u/16846702?s=400&v=4" alt="yanchao891012"></a><a style="border:0" href="https://github.com/noctwolf" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars3.githubusercontent.com/u/21022467?s=400&v=4" alt="noctwolf"></a><a style="border:0" href="https://github.com/xianyun666" target="_blank" rel="noopener"><img width="120" height="120" src="https://avatars1.githubusercontent.com/u/22339210?s=400&v=4" alt="xianyun666"></a></p>
|
||||
|
||||
# 感谢以下组织机构提供开源许可
|
||||
|
||||
<p><a style="border:0" href="https://www.jetbrains.com/?from=HandyControl" target="_blank" rel="noopener"><img width="70" height="70" src="https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/resharper_logo.png" alt="JetBrains"></a></p>
|
||||
<p><a style="border:0" href="https://www.jetbrains.com/?from=HandyControl" target="_blank" rel="noopener"><img width="70" height="70" src="https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/resharper_logo.png" alt="JetBrains"></a></p>
|
||||
|
||||
# 感谢以下捐赠者
|
||||
|
||||
|
||||
@@ -3,4 +3,9 @@
|
||||
margin: 3px;
|
||||
display: inline;
|
||||
padding: 3px !important;
|
||||
}
|
||||
|
||||
.post-body h2 {
|
||||
font-size: 1.45em;
|
||||
border-bottom: 0px solid #eee;
|
||||
}
|
||||
@@ -9,17 +9,17 @@ namespace HandyControl.Tools.Converter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Thickness cornerRadius)
|
||||
if (value is Thickness thickness)
|
||||
{
|
||||
if (parameter is string str)
|
||||
{
|
||||
var arr = str.Split(',');
|
||||
if (arr.Length != 4) return cornerRadius;
|
||||
if (arr.Length != 4) return thickness;
|
||||
|
||||
return new CornerRadius(arr[0].Equals("1") ? cornerRadius.Left : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Top : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Right : 0,
|
||||
arr[1].Equals("1") ? cornerRadius.Bottom : 0);
|
||||
return new Thickness(arr[0].Equals("1") ? thickness.Left : 0,
|
||||
arr[1].Equals("1") ? thickness.Top : 0,
|
||||
arr[1].Equals("1") ? thickness.Right : 0,
|
||||
arr[1].Equals("1") ? thickness.Bottom : 0);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
|
||||