-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 ??

21
  • Go, so you also create custom controls and class libraries in C #. Then we have something in common ;-) Commented Apr 9, 2018 at 16:33
  • I like it, so I upvote ;-) Commented Apr 9, 2018 at 16:34
  • @HéctorManuelMartinezDurán , thanks man ..... but mind if i ask, what did u like about the qs ? Commented Apr 9, 2018 at 16:52
  • owwwww.....u are the guy !!! i just saw ur profile and remembered who u are man .... tnx anyway ...cheers Commented Apr 9, 2018 at 16:53
  • Then you had forgotten who I was, go, and I worried ;-) Commented Apr 9, 2018 at 17:09

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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.
What do you not understand about the information you found when you looked for yourself?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.