locked
Refer to an XAML element in .cs RRS feed

  • Question

  • Hi all,

    I made a button in my main file (SurfaceWindow1.xaml) with this code in the .cs file.

     

    void changeMapStyleHy(object sender, EventArgs e)
    {
    SurfaceMap.MapStyle = InfoStrat.VE.VEMapStyle.Hybrid;
    }

     

    Works fine, no problems there.

    I created an extra xaml file which loads when I place a tag on the screen (I'm developing on a Surface Table). This works fine too.

    Now, when I create a button in this second xaml file, I can't 'call' "SurfaceMap" since it's in my main xaml file. How can I refer to this element?

     

    Thanks in advance!

    Wednesday, May 12, 2010 11:46 AM

All replies

  • What are you trying to accomplish? Modify the SurfaceMap style from another page? Is your other xaml file a control or what?

    If thats the case you can pass SurfaceMap through a function to your other file. How is your other file being called or instantiated? Whever you create an instance of this xaml file just pass in the SurfaceMap element as a reference to your other file.

    Just create a constructor that takes a reference to that type you want and then when you instantiate the control/file just pass the reference

    MyXamlFile file = new MyXamlFile(SurfaceMap)

     

    Wednesday, May 12, 2010 4:00 PM