Skip to main content
Home Forums General Silverlight Getting Started refresh the application
8 replies. Latest Post by le_beluet on November 5, 2009.
(0)
le_beluet
Member
30 points
45 Posts
11-01-2009 10:04 AM |
I do update a texblock located in a user control from XML file data in my appplication but the new content of the textblock is not updated
How can I refresh the appplications
Here the code
. . . Operator_name = XmlTemplate.DescendantsAndSelf("Operators").First().Element("Operator_name").Value.ToString(); //display the operator name in the application title usr control PutOperatorName(Operator_name); private void PutOperatorName( string name) { ctrl_ApplicationTitle t = new ctrl_ApplicationTitle(); t.OperatorName.Text = name.ToString(); }
bryant
Star
9937 points
1,629 Posts
11-01-2009 10:29 AM |
What kind of object is ctrl_ApplicationTitle? Is it a user control? If so you'll need to get the existing user control and update that one not create a new instance in order to update it.
11-01-2009 11:31 AM |
It's a user control
<!--application Title--> <controls:Viewbox HorizontalAlignment="Left" Grid.Row="0" Stretch="UniformToFill"> <LS:ctrl_ApplicationTitle x:Name="Title"/> </controls:Viewbox >
Can you tell me how to access my user control from code behind
11-01-2009 11:34 AM |
The issue is that your control is in a viewbox. You can find a way to access the child control here.
11-01-2009 5:53 PM |
Thanks for the Info. but I have another problem
the procedure who will update the value is located in another user control ("UsrCtrl_Menu") not in the main page
I need to know how to reference ViewAppTitle (viewbox) in the user control ("UsrCtrl_Menu")
See the error below.
Error 2 'Loadsheet_sl3.UsrCtrl_Menu' does not contain a definition for 'ViewAppTitle' and no extension method 'ViewAppTitle' accepting a first argument of type 'Loadsheet_sl3.UsrCtrl_Menu' could be found (are you missing a using directive or an assembly reference?) I:\Documents\Visual Studio 2008\Projects\SL3\Loadsheet_sl3\Loadsheet_sl3\UsrCtrl_Menu.xaml.cs 79 22 Loadsheet_sl3
Min-Hong...
Contributor
3375 points
377 Posts
11-04-2009 5:20 AM |
Hi,
Can you tell us more information about your scenerio. To get a reference of your control is easy, just do according xx said. The problem is how you pass it.
To provide you a solution , we need to know about how you managed your different controls. For example , are you using navigation application?
If you are using this.Content = new Page2() as a navigationg method. You can even pass your value in the constructor.
Anyway, we are expecting more informations.
Best Regards
11-04-2009 6:06 AM |
Sorry' I was in volley ball coach evalution these last days. I will make a small scenarion to night.
But for now you can see the demo http://mpeapps.com/Demobeta.aspx
you will need to download the xml file here from this page http://mpeapps.com/DemoBetaRoadMap.aspx . or save the target form this link.
http://mpeapps.com/ClientBin/Operator_Template.xml
Here the step
From the menu file (located in a view box) click on read template and select the xml template. you will see a message box that state operator1.
I'm try to put this value in a user control (header.xaml) located above the menu which is also in a viewbox. In this way my apps resize easily without code behind for resizing feature.
The user control (header.xaml) has 2 text blocks. One for the apps name and one for the operator name.
hope this help to understand my issue.
11-04-2009 6:50 AM |
Based on my understanding, you nested several user controls into a mainpage. And you want to pass value between them.
I build a similar situation. I created two user controls and nest them to my main page. Each of them contains a viewbox in it, and inside the viewbox there are some target controls we need to get.
Here is how i do it in the mainpage.
Grid i = VisualTreeHelper.GetChild(sl1,0) as Grid; // s1 is my usercontrol's x:name Viewbox v = VisualTreeHelper.GetChild(i, 0) as Viewbox; TextBlock tb = v.FindName("tb") as TextBlock; // this is nest in the view box
And use the same method to get a reference of another target. So you got reference to the objects , now you may do things.
Since your controls are in the same page. Actual you need to deal with is the visual tree. You can get more inforamtion here:
http://msdn.microsoft.com/en-us/library/ms753391.aspx
Hope it helps.
11-05-2009 6:47 AM |
thanks a lot