-1

I have a Window(mainwindows.xaml) where there's a label.Now,i've created a UserControl(Just a basic button)..On Window_load,i'm adding the UserControl in a canvas(in mainwindow) using this :

Dim con as new myUserControl

Canvas.Children.Add(con)

Now What i want is,when i click the UserControl,the label will be hidden..How do i do this ??

I've tried creating a WPF CUSTOM CONTROL LIBRARY but don't know how to work with it ??

braX
  • 11,506
  • 5
  • 20
  • 33
Software Dev
  • 5,368
  • 5
  • 22
  • 45

1 Answers1

1

Fixed it myself....Guess that was really easy.In usercontrol,just used this :

   Dim hm As MainWIndow = Window.GetWindow(Me)
   hm.Lbl1.Visibility=Visibility.Hidden
Software Dev
  • 5,368
  • 5
  • 22
  • 45
  • 3
    That's pretty horrible code really. For a start, it requires `Option Strict Off`. The UC shouldn't have to have such specific knowledge of the window it's on. The correct way to do that is for the UC to raise an event and for the window to handle that event and hide the `Label` itself. – jmcilhinney Jan 31 '18 at 05:14
  • What do you not understand about the information you found when you looked for yourself? – jmcilhinney Jan 31 '18 at 08:50