1.UI代码
<Button Background="Black" BorderBrush="Transparent" Padding="0" HorizontalContentAlignment="Left" Style="{StaticResource ButtonEmpty}"
Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:Valve1h}}, Path=ValueCmd}"
CommandParameter="{Binding ElementName=ID,Path=Text }" Cursor="Hand" IsHitTestVisible="True"/>
注释:属性绑定释义
Command--Ancestor 查找绑定至自定义控件Valve1h,实体命令绑定本地自建依赖属性ValueCmd
CommandParameter--绑定本地TextBlock控件Name为ID,Path为其文本值
2.cs代码
2.1 string依赖属性及属性值变化回调函数
public static readonly DependencyProperty ValueLabelProperty =
DependencyProperty.Register("ValueLabel", typeof(string),
typeof(Valve