WPF Kullanıcı Denetimi Üst | Netgez.com
SORU
19 Kasım 2008, ÇARŞAMBA


WPF Kullanıcı Denetimi Üst

Ben zamanında bir kullanıcı bir ana pencere içine benim yük var kontrol edin. Yapamam kullanıcının bulunduğu pencere üzerinde kontrolü ele almak.

Bunu denedim.Üst, ama her zaman boş. Herkes bir kullanıcı içeren pencere WPF kontrolü ele almak için nasıl biliyor mu?

Denetimi nasıl yüklenir:

private void XMLLogViewer_MenuItem_Click(object sender, RoutedEventArgs e)
{
    MenuItem application = sender as MenuItem;
    string parameter = application.CommandParameter as string;
    string controlName = parameter;
    if (uxPanel.Children.Count == 0)
    {
    	System.Runtime.Remoting.ObjectHandle instance = Activator.CreateInstance(Assembly.GetExecutingAssembly().FullName, controlName);
    	UserControl control = instance.Unwrap() as UserControl;
    	this.LoadControl(control);
    }
}

private void LoadControl(UserControl control)
{
    if (uxPanel.Children.Count > 0)
    {
    	foreach (UIElement ctrl in uxPanel.Children)
    	{
    		if (ctrl.GetType() != control.GetType())
    		{
    			this.SetControl(control);
    		}
    	}
    }
    else
    {
    	this.SetControl(control);
    }
}

private void SetControl(UserControl control)
{
    control.Width = uxPanel.Width;
    control.Height = uxPanel.Height;
    uxPanel.Children.Add(control);
}

CEVAP
20 Kasım 2008, PERŞEMBE


Aşağıdaki kullanmayı deneyin

Window parentWindow = Window.GetWindow(userControlRefernce);

GetWindow yöntemi sizin için VisualTree yürüyüş ve denetimi barındıran bir pencere bulur.

Bunu PaylaÅŸ:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ★ByScrapi★ Designs

    ★ByScrapiâ

    27 AÄžUSTOS 2013
  • cekehechu

    cekehechu

    20 HAZİRAN 2006
  • Vintendo Power

    Vintendo Pow

    2 Ocak 2007