0
我想在將窗口顯示爲對話框之前清除WPF窗口內的TextBlock文本。文本塊文本僅在調用ShowDialog窗口時清除WPF
但TextBlock上的文本顯示一秒的先前值,然後自動清除。
有沒有可能在將窗口顯示爲對話框之前清除文本?
這裏是我的代碼片段:
//Code in Window Control:
public string PopupTitle
{
get
{
string response = string.Empty;
this.Dispatcher.Invoke((Action)delegate
{
response = lbl_PopupTitle.Text;
}, null);
return response;
}
set
{
this.Dispatcher.Invoke((Action)delegate
{
lbl_PopupTitle.Text = value;
lbl_PopupTitle.Visibility = string.IsNullOrEmpty(value) ? Visibility.Collapsed : Visibility.Visible;
}, null);
}
}
//Code to call this window:
PopupWindow popup = new PopupWindow();
popup.PopupTitle = string.Empty;
popup.ShowDialog();