1
在点击事件中,我想在后面的代码中显示一个弹出窗口,但弹出窗口不显示?弹出窗口不显示
void PopupDisplay_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
if (sender != null)
{
p = new Popup
{
Width = 480,
Height = 580,
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
VerticalAlignment = System.Windows.VerticalAlignment.Center
};
Border b = new Border();
b.BorderBrush = new SolidColorBrush(Colors.Gray);
b.BorderThickness = new Thickness(2);
b.Margin = new Thickness(10, 10, 10, 10);
p.Child = b;
p.IsOpen = true;
}
}
不知也许'Popup'是走出去范围和被处置?尝试在此方法之外定义一次'Popup',然后在需要显示时调用'IsOpen = true'。只是一个猜测 - 我不是一个Windows手机开发。 – 2014-11-02 15:59:55
从你的代码中我注意到了Popup没有添加到可视化树中。 – 2014-11-02 21:19:36