private void OpenPhoneNumber()
{
PhoneNumber p = new PhoneNumber();
p.Margin = new Thickness { Left = 20, Top = 20 };
grid.Children.Add(p);
grid.RegisterName("PhoneNumber", p);
}
private void ClosePhoneNumber()
{
var p = grid.FindName("PhoneNumber") as PhoneNumber;
if (p != null)
{
grid.Children.Remove(p);
grid.UnregisterName("PhoneNumber");
}
}
Button b1 = new Button();
b1.Content = "abcd";
Canvas cv = new Canvas();
Canvas cv2 = new Canvas();
cv2.Children.Add(b1);
Canvas.SetTop(cv2, 20);
cv.Children.Add(cv2);
Menu m = new Menu();
m.Height = 20;
MenuItem mi = new MenuItem();
mi.Header = "m1";
MenuItem mi2 = new MenuItem();
mi2.Header = "m2";
mi.Items.Add(mi2);
m.Items.Add(mi);
cv.Children.Add(m);
w1.Content = cv;
总比没有的好!