【发布时间】:2018-01-18 06:03:51
【问题描述】:
我有一个似乎无法通过 Google 解决的问题(可能是因为我没有搜索正确的标准)。我有一个关闭事件,它检查是否启用了按钮并弹出一个带有结果的消息框(是/否)。如果用户说不,我会在应用程序中得到想要的结果;但是,右上角的 X 停止工作。如何“恢复”关闭按钮(右上角的“X”),以便在按下时再次工作(并再次评估逻辑)。
我试过这个:Stackoverflow Question
我不认为我想玩窗口的可见性。窗户哪儿也去不了。他们有脏数据,需要修复或自动保存。
我在应用程序中拥有的是:
private void DXWindow_Closing(object sender, CancelEventArgs e)
{
if (BtnPatSave.IsEnabled == false) return;
if (MessageBox.Show(Properties.Resources.PatAcctMsgBox3, Properties.Resources.PatAcctMsgBox1,
MessageBoxButton.YesNo,
MessageBoxImage.Warning) == MessageBoxResult.No)
{
e.Cancel = true;
}
else
{
var patId = TbPatId.Text;
var usl = new UnSetLockValue();
usl.UnSetVal(patId);
Log.Info("Patient Account is now unlocked by user: " + Environment.UserName);
}
}
【问题讨论】:
-
解决了我自己的问题。在加载的事件中, var b = LayoutHelper.FindElement(this, o => { if (o is Button) return o.Name == "PART_CloseButton"; return false; }) as Button; b.Visbility = Visibility.Collapsed;