Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys

I work on silverlight 5 and have a polling duplex wcf service to manage lights in a building.

I've 2 pages, lets say Parent.xaml and Child.xaml. Child is inside Parent with a frame. From Child I'd like to make visible or not a Textblock in Parent page. I try calling a public method on Parent page from Child page, but the visibility is set to Visible but nothing change on screen. It's like the Textblock was behind something or I was trying make changes on another thread....

Why does this textblock don't appear on my screen when it's correctly set to Visible?!?

C#
public void InfoIsVisible(bool visibility)
        {
            if (visibility == true)
            {
                proxy.Abort();
                loadInfos();

                txtConnection.Visibility = Visibility.Visible;

                error.Text("Msg state : " + txtConnection.Visibility.ToString());
                error.Show();
            }
            else
            {
                txtConnection.Visibility = Visibility.Collapsed;
            }
        }
Posted
Comments
Sangramsingh Pawar 17-Aug-12 3:39am    
put your code in which InfoIsVisible() called in your child page

1 solution

Hi,try this solution:
C#
public void InfoIsVisible(bool visibility)
        {
            if (visibility == true)
            {
                proxy.Abort();
                loadInfos();

                txtConnection.Visibility = Visibility.Visible;

                error.Text("Msg state : " + txtConnection.Visibility.ToString());
                error.Show();
            }
            else
            {
                MainPage m = (MainPage)Application.Current.RootVisual;
                m.txtConnection.Visibility = Visibility.Collapsed;
            }
        }
 
Share this answer
 
Comments
Sangramsingh Pawar 17-Aug-12 3:47am    
good ans My 5+
Member 8295307 17-Aug-12 4:39am    
Hi I try your solution like this, but get an error : Unable to cast MainPage in Navigation.Automation

MainPage contains Automation (Page type, the Parent in my explanation) who contains Lumiere (Page type, the Child who wants to interact with the Parent)


public void InfoIsVisible(bool visibility)
{
if (visibility == true)
{
proxy.Abort();
loadInfos();

//MainPage m = (MainPage)Application.Current.RootVisual;
Automation aut = (Automation)Application.Current.RootVisual;
aut.txtConnection.Visibility = Visibility.Visible;

error.Text("état du msg : " + txtConnection.Visibility.ToString());
error.Show();
}
else
{
txtConnection.Visibility = Visibility.Collapsed;
}
}
Member 8295307 17-Aug-12 6:35am    
OK I change a litle bit the config and put txtConnection on the MainPage and it's working. Thanks for your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900