一、系统操作
1.屏蔽输入框的输入法输入
<!-- 屏蔽输入法 在样式中设置 -->
<Setter Property="InputMethod.IsInputMethodEnabled" Value="False"/>
<!-- 屏蔽输入法 在属性中设置 -->
<Ctrls:MyNumericBox x:Name="pwd" InputMethod.IsInputMethodEnabled="False" HorizontalAlignment="Left" Margin="115,146,0,0" VerticalAlignment="Top" Width="75"/>
2.获取软件版本
//通过system获取
System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
//通过application获取
Application.ResourceAssembly.GetName().Version.ToString();
3.窗口拖动(拖拽)
/// <summary>
/// 鼠标移动事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
try
{
this.DragMove();
}
catch (InvalidOperationException err)
{
UdMessageBox.Show(err.Message);
}
}
}
注意:若窗口中存在ComboBox或者TextBox进行拖拽是会报错“InvalidOperationException”,而且try catch无法捕获该异常,会直接报错,然后闪退,需要注意阻断此类控件的冒泡路由事件传递。或者单独放置一个控件,触发后直接阻断路由事件,e.Handled = true;
二、兼容性问题
1.关于引用的控件兼容问题
win7 无法识别:PresentationFramework.Aero2只能识别PresentationFramework.Aero
win10可以识别:PresentationFramework.Aero2和PresentationFramework.Aero2
win7环境下运行调用PresentationFramework.Aero2的应用程序会无法正常运行,并且不会报错,需要再win7环境下运行调试时才会报错。