modified the branch

This commit is contained in:
NaBian committed 2019-06-17 22:18:43 +08:00
1 parent a8e5738c89
commit 76f38433b5
2 files changed
+22 -37

No files matched your search

@@ -1,57 +1,42 @@
---
title: BackgroundSwitchElement
title: BackgroundSwitchElement 可切换背景的元素
---
### 附件属性名称
* MouseHoverBackground 鼠标悬浮背景颜色
* MouseDownBackground 鼠标按下背景颜色
### 准备工作
使用的当前`.xaml`页面中引入`HandyCntrol`的控件命名空间
# 准备工作
添加`HandyControl`命名空间
{% code %}
xmlns:controls="https://handyorg.github.io/handycontrol"
或
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"(老版本)
xmlns:hc="https://handyorg.github.io/handycontrol"
{% endcode %}
### MouseHoverBackground `鼠标悬浮背景颜色`
用途:该附加属性常用于自定义控件`Style`时,鼠标悬浮在控件上,属性触发器`IsMouseOver`为`true`时,设定目标控件当前鼠标悬浮状态背景色。
## MouseHoverBackground `鼠标悬浮背景色`
{% note info no-icon %}
#### 视图控件内添加MouseHoverBackground属性:
该附加属性常用于设置控件在鼠标悬浮时的背景色,在控件的样式或者模板中我们添加如下的触发器代码:
{% endnote %}
{% code %}
<控件 controls:BackgroundSwitchElement.MouseHoverBackground ="Blue"/>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Chrome" Value="{Binding Path=(controls:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
{% endcode %}
随后我们就可以使用该属性了:
{% note info no-icon %}
#### IsMouseOver属性触发中使用如下:
{% endnote %}
{% code %}
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Chrome"
Value="{Binding Path=(controls:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<目标控件 controls:BackgroundSwitchElement.MouseHoverBackground ="Blue"/>
{% endcode %}
## MouseDownBackground `鼠标按下背景色`
### MouseDownBackground `鼠标按下背景颜色`
用途:该附加属性常用于自定义控件`Style`时,鼠标悬浮在控件上,属性触发器`IsPressed`为`true`时,设定目标控件当前鼠标按下状态背景色。
该附加属性常用于设置控件在鼠标按下时的背景色,在控件的样式或者模板中我们添加如下的触发器代码:
{% note info no-icon %}
#### 视图控件内添加MouseDownBackground属性:
{% endnote %}
{% code %}
<控件 controls:BackgroundSwitchElement.MouseDownBackground ="Yellow"/>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="Chrome"
Value="{Binding Path=(controls:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
{% endcode %}
{% note info no-icon %}
#### IsPressed属性触发中使用如下:
{% endnote %}
随后我们就可以使用该属性了:
{% code %}
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="Chrome"
Value="{Binding Path=(controls:BackgroundSwitchElement.MouseHoverBackground),RelativeSource={RelativeSource TemplatedParent}}"/>
</Trigger>
<目标控件 controls:BackgroundSwitchElement.MouseDownBackground ="Yellow"/>
{% endcode %}