如何使Textblock从子页面可见到父页面 [英] How to make Textblock visible from child page into parent page
问题描述
大家好
我正在使用Silverlight 5,并且具有轮询双工wcf服务来管理建筑物中的灯光.
我有2页,可以说Parent.xaml和Child.xaml.孩子在父母里面有框架.对于孩子,我希望在父"页面中显示或不显示文本块.我尝试在子级"页面的父级"页面上调用公共方法,但是可见性设置为可见",但屏幕上没有任何变化.就像Textblock在某些东西后面,或者我正在尝试在另一个线程上进行更改....
正确设置为可见"后,为什么此文本块不会出现在我的屏幕上?!?
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?!?
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;
}
}
推荐答案
尝试以下解决方案:
Hi,try this solution:
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;
}
}
这篇关于如何使Textblock从子页面可见到父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!