輪班其他控制當我添加彈出我的XAML這樣添加使用XAML彈出控制
<Grid>
...other controls
<Popup x:Name="popup" Width="200" Height="200" >
</Popup>
</Grid>
它的行爲就好像在彈出的有,即使我沒有切換ISOPEN = TRUE(但空間是空白的,所以沒有彈出窗口是可見的)
但是,當我從後面的代碼(添加一個彈出)這樣做,它的工作原理就像它應該,它不會干擾任何控制(即移動它們)和它按預期在其他控件上方彈出。
Popup p = new Popup();
// Create some content to show in the popup. Typically you would
// create a user control.
Border border = new Border();
border.BorderBrush = new SolidColorBrush(Colors.Black);
border.BorderThickness = new Thickness(0);
StackPanel panel1 = new StackPanel();
panel1.Background = new SolidColorBrush(Colors.);
Button button1 = new Button();
button1.Content = "Close";
button1.Margin = new Thickness(5.0);
button1.Click += new RoutedEventHandler(Feedback_Click);
TextBlock textblock1 = new TextBlock();
textblock1.Text = "The popup control";
textblock1.Margin = new Thickness(5.0);
panel1.Children.Add(textblock1);
panel1.Children.Add(button1);
border.Child = panel1;
// Set the Child property of Popup to the border
// which contains a stackpanel, textblock and button.
p.Child = border;
// Set where the popup will show up on the screen.
p.VerticalOffset = 400;
p.HorizontalOffset = 150;
// Open the popup.
p.IsOpen = true;
有誰知道我該如何在XAML中完成同樣的事情?
當我在我的電腦上試用這個功能時,它在運行時表現正確。在設計時它佔據了空間。這是你所經歷的行爲嗎?看起來你在後面的代碼中使用XAML中的'Grid'和'StackPanel'。提醒一下,這些容器的行爲非常不同。 – Default