Skip to main content

Microsoft Silverlight

Answered Question refresh the applicationRSS Feed

(0)

le_beluet
le_beluet

Member

Member

30 points

45 Posts

refresh the application

 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(); 

        }
 

 

Jean-MARC Flamand
http://mpeapps.com/

bryant
bryant

Star

Star

9937 points

1,629 Posts

Silverlight MVP

Re: refresh the application

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.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

le_beluet
le_beluet

Member

Member

30 points

45 Posts

Re: Re: refresh the application

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

 

Jean-MARC Flamand
http://mpeapps.com/

bryant
bryant

Star

Star

9937 points

1,629 Posts

Silverlight MVP

Re: Re: refresh the application

The issue is that your control is in a viewbox. You can find a way to access the child control here.

-- bryant

Blog | Twitter
_________________
Dont forget to click "Mark as Answer" on the post that helped you.

le_beluet
le_beluet

Member

Member

30 points

45 Posts

Re: Re: Re: refresh the application

 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
 

Jean-MARC Flamand
http://mpeapps.com/

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3375 points

377 Posts

Re: Re: Re: refresh the application

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

  

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

le_beluet
le_beluet

Member

Member

30 points

45 Posts

Re: Re: Re: refresh the application

 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

 

Normal 0 21 false false false FR-CA X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

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.

Jean-MARC Flamand
http://mpeapps.com/

Min-Hong Tang - MSFT
Min-Hong...

Contributor

Contributor

3375 points

377 Posts

Answered Question

Re: Re: Re: refresh the application

Hi,

   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.

Best Regards

Min-Hong Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

le_beluet
le_beluet

Member

Member

30 points

45 Posts

Re: Re: Re: Re: refresh the application

 thanks a lot

Jean-MARC Flamand
http://mpeapps.com/
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities