add doc of visualelement and windowattach

This commit is contained in:
guanguanchuangyu committed 2019-11-18 21:31:00 +08:00
1 parent 334b2269b6
commit a2684e679e
2 files changed
+129 -4

No files matched your search

@@ -1,5 +1,79 @@
---
title: 建设中
title: VisualElement 可视化元素
---
建设中
# 属性
| 名称 | 用途 |
| -------------- | ---------------- |
| HighlightBrush | 设置控件高亮颜色 |
| Text | 设置文本内容 |
# 使用案例
对应`xaml`中添加`HandyControl`对应的命名空`xmlns:hc="https://handyorg.github.io/handycontrol"`
## HighlightBrush 设置控件高亮颜色
```xml
<UniformGrid Margin="22,22,0,0" Rows="2" Columns="2">
<RadioButton Margin="10,10,0,0" Background="{DynamicResource SecondaryRegionBrush}"
Style="{StaticResource RadioButtonIcon}"
Content="RadioButton" IsChecked="True"
GroupName="radio1"/>
<RadioButton Margin="10,10,0,0" BorderThickness="1"
Style="{StaticResource RadioButtonIcon}"
hc:VisualElement.HighlightBrush="YellowGreen"
Content="RadioButton"
GroupName="radio2"/>
</UniformGrid>
```
如下截图为一组选中状态时的高亮对比结果,左图为样式`默认颜色`,右侧为个人`自定义颜色`
![VisualElement.HighlightBrush](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/attach/VisualElement.HighlightBrush.png)
## Text 设置文本内容
可视化文本内容,主要用于微软`WPF`库中原生控件需要显示辅助文本,但并没有对应的文本内容显示属性时,通过控件的自定义样式时,使用此附加属性进行进行文本内容的显示。
例如:当自定义进度条,需要显示文本时,本身缺少显示额外文本内容的属性,可以通过自定样式显示对应文本,以`Text`作为文本内容承载属性
自定义样式:
```xml
<Style x:Key="ProgressBarBaseStyle" TargetType="ProgressBar">
<Setter Property="controls:VisualElement.Text">
<Setter.Value>
.....忽略代码.....
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar">
<controls:SimplePanel x:Name="TemplateRoot">
....忽略代码....
<controls:SimplePanel HorizontalAlignment="Left">
....忽略代码....
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource TextIconBrush}" Text="{Binding Path=(controls:VisualElement.Text),RelativeSource={RelativeSource TemplatedParent}}"/>
</controls:SimplePanel>
</controls:SimplePanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
```
`xaml`中的使用:
```xml
<UniformGrid Margin="22,22,0,0" Rows="2" Columns="2">
<ProgressBar Style="{DynamicResource ProgressBarDanger}"
hc:VisualElement.Text="这是可视化文本"
Background="YellowGreen"></ProgressBar>
</UniformGrid>
```
效果:
![VisualElement.Text](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/attach/VisualElement.Text.png)
@@ -1,5 +1,56 @@
---
title: 建设中
title: WindowAttach 窗体专用
---
建设中
# 属性
| 名称 | 用途 |
| ----------------- | ------------------------------------------------------------ |
| IsDragElement | 是否允许当前元素可拖动窗体 |
| IgnoreAltF4 | 是否忽略快捷键Alt和F4(键盘快速退出或者 结束 当前正在运行的应用程序) |
| ShowInTaskManager | 是否窗体显示到任务管理器中 |
# 使用案例
对应`xaml`中添加`HandyControl`对应的命名空`xmlns:hc="https://handyorg.github.io/handycontrol"`
```xml
<hc:BlurWindow x:Class="类命名空间"
.....常规项......
WindowStartupLocation="CenterScreen"
ShowTitle="True"
Style="{DynamicResource WindowBlur}"
xmlns:hc="https://handyorg.github.io/handycontrol"
d:DesignHeight="450" d:DesignWidth="800">
<hc:SimplePanel>
<Rectangle VerticalAlignment="Top" Margin="10" Height="30" RadiusX="4" RadiusY="4" Stroke="{DynamicResource BorderBrush}" StrokeDashArray="2,2"/>
<Border hc:WindowAttach.IsDragElement="True" VerticalAlignment="Top" Margin="11" Height="28" Background="{DynamicResource DarkDefaultBrush}" CornerRadius="4">
<TextBlock Text="DragHere" Style="{StaticResource TextBlockDefault}"/>
</Border>
<Button HorizontalAlignment="Right" Margin="0,15,15,0" VerticalAlignment="Top" Padding="0" Height="20" Width="20" Style="{StaticResource ButtonPrimary}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" hc:BorderElement.CornerRadius="15"/>
</hc:SimplePanel>
</hc:BlurWindow>
```
可在深色框区域鼠标拖动窗体
![WindowAttach.IsDragElement](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Doc/attach/WindowAttach.IsDragElement.png)
# IgnoreAltF4 是否忽略快捷键Alt和F4
常用于自定义设定需要手动关闭当前激活状态的应用程序,如`HandyControl`中的`Notifycation`或者`NotifyIcon`控件,默认为False
```xml
<Setter Property="hc:WindowAttach.IgnoreAltF4" Value="True"/>
```
## ShowInTaskManager 是否窗体显示到任务管理器中
设定`Window`控件及其子类是否显示在任务管理器中
使用前提:
- 窗体的实例显示时,不使用`ShowDialog`
- 同时设置`ShowInTaskBar`为`false`
ps:该附加属性在`Windows7`中效果不是很明显