其他分享
首页 > 其他分享> > wpf 控件注意事项

wpf 控件注意事项

作者:互联网

1.阴影
<Border.Effect>
<DropShadowEffect Color="Gray" Direction="320" BlurRadius="20" Opacity="0.7" ShadowDepth="10"/>
</Border.Effect>

 

2.在Loaded中添加控件的按键事件,但对类似于Popup没有焦点的控件无效
private void Loaded(Popup obj)
{
obj.KeyDown += (sender, e) =>
{
if (e.Key == Key.Enter)
{
PopTimeClose(obj);
}
};
}

去掉聚焦是的虚线<Setter Property="FocusVisualStyle" Value="{x:Null}" />

父容器强制获取子项焦点FocusManager.FocusedElement="{Binding ElementName=btn}"

当为可聚焦性控件是可用如下Mouse+Enter事件
<Button.InputBindings>
<KeyBinding Command="{Binding CmdPopDailyExpenseInstrust1_KeyClose}"
CommandParameter="{Binding ElementName=Pop_DailyExpenseInstrust1}"
Key="Enter"
Modifiers="Alt"/>

<MouseBinding Command="{Binding CmdPopDailyExpenseInstrust1_MouseClose}"
CommandParameter="{Binding ElementName=Pop_DailyExpenseInstrust1}"
MouseAction="RightClick"/>

</Button.InputBindings>

 

textBox 按键事件
<i:Interaction.Triggers>
<ei:KeyTrigger FiredOn="KeyUp" Key="Return">
<i:InvokeCommandAction Command="{Binding CmdPopDailyExpenseAbstract1_KeyClose}"/>
</ei:KeyTrigger>
</i:Interaction.Triggers>

标签:控件,ElementName,obj,注意事项,Binding,Key,Enter,wpf
来源: https://www.cnblogs.com/mamaxiaoling/p/11439322.html