Question : WPF Control will not hide button or check box....

I have a control that is being called from another form.  Everything displays and works great.  Then I try to use the same control to hide buttons and check boxes depending on what form is calling the control.

When I use the immediate window it is showing in the control that the objects (button and checkbox) are hidden but when I let the application load the form has the object visible.

Maybe it needs refreshed?  The event I am using to call it is "loaded" so maybe it is already loaded before I can change it?  Not being asp.NET there isn't a Init event of any sort.  I am an ASP.NET web developer and having not used WPF before it is very, very different.

Please give me your thoughts folks.

Thanks in advance for your time and efforts,

B
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
Code from the control: 
        Public Sub SetVisibility(ByVal Page As String) 
            Dim SearchPersonPage As String = "SearchPerson.xaml"
            Dim InputPersonPage As String = "EnterPerson.xaml" 
            If Page = InputPersonPage Then 
                btnAddAddress.Visibility = Windows.Visibility.Visible
                cbxDefaultAddress.Visibility = Windows.Visibility.Visible 
            Else 
                btnAddAddress.Visibility = Windows.Visibility.Hidden
                cbxDefaultAddress.Visibility = Windows.Visibility.Hidden 
            End If 
        End Sub 
 
Code from the form calling the control: 
        Private Sub SearchPerson_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded 
            Dim page As New Address
            Dim PageString As String = Parent.ToString
            Dim k As String = Name.ToString 
            page.SetVisibility(PageString)
            page.BeginInit()
            rxpAddressInformation.UpdateLayout() 
        End Sub

Answer : WPF Control will not hide button or check box....

Greetings,

I am not a 100% sure about what you are trying to achieve but i see a few things which seems suspicious.
Your method SetVisibility looks fine (even though i would not personally hard code strings). However in your SearchPerson_Loaded method I don't understand why you do this "Dim page As New Address"
I assume that "Address" is the control you are trying to use and thus why would you initialize it instead of using a reference to an already existing control like "me.page" or "someWindowReference.page".
Also, you should remove "page.BeginInit()" as you should not be calling this function if I understood your scenario correctly.

hope this is making sense!

Random Solutions  
 
programming4us programming4us