XML dropdown

I have the following XML which I am calling upon for a dropdown box. However, I want the dropdown box to display a value from another function that I have called 'Setting.RunCount.ToString. My XML so far is :

<Glide Version="1.0.5">
  <Window Name="window" Width="480" Height="272" BackColor="dce3e7">
  <TextBlock Name="RunCountTextBlock" X="100" Y="160" Width="120" Height="32" Alpha="255" Text="Scroll" TextAlign="Right" TextVerticalAlign="Middle" Font="3" FontColor="000000"/>
 
 [b]  <Dropdown Name="dropdown" X="10" Y="90" Width="160" Height="32" Alpha="255" Value= "Settings.RunCount.ToString()" Text= "" Font="4" FontColor="000000"> [/b]
   


 <Option Value="Data0">Label0</Option>
      <Option Value="Data1">Label1</Option>
      <Option Value="Data2">Label2</Option>
      <Option Value="Data3">Label3</Option>
      <Option Value="Data4">Label4</Option>
      <Option Value="Data5">Label5</Option>
      <Option Value="Data6">Label6</Option>
      <Option Value="Data7">Label7</Option>
      <Option Value="Data8">Label8</Option>
      <Option Value="Data9">Label9</Option>
    </Dropdown>
  </Window>
</Glide>


As you can see I have attempted to call upon it with value = "Settings.RunCount.ToString(). I;m not sure if the formatting of this is correct, and also if I have to put anything in ‘text=’. Thanks.

This is an issue of you are trying to access logical variables from within an XML data sheet, which does not have access to the scope of your program. For you to get your data in the XML value attribute, you will have to inject the data manually before passing it to the interpreter:


string value = "<Option Value=\"" + Setting.RunCount.ToString() + "\">Label1</Option>";

Oh I see, it isn’t the XML that I will have to alter?
My code is

using Microsoft.SPOT;
using System.Threading;
using GHIElectronics.NETMF.Glide;
using GHIElectronics.NETMF.Glide.Display;
using GHIElectronics.NETMF.Glide.UI;
using System.Collections;


namespace DropDown_with_EWR
{

    public class Program
    {
        //This will hold the windows
        static Window window = null;


        //This will hold the list
        static List list = null;

        public static ExtendedWeakReference settingsReference;
        public static AppSettings Settings;

        public static void Main()
        {
            // Reads data from FLASH memory.
            // If no entry with AppSettings/0 identifier exists in memory, a new one is created.


            settingsReference = ExtendedWeakReference.RecoverOrCreate(typeof(AppSettings), 0, ExtendedWeakReference.c_SurvivePowerdown);

            // If the entry was just created, its value is set to null.
            if (settingsReference.Target == null)

                Settings = new AppSettings();

            else
                Settings = (AppSettings)settingsReference.Target; // EWR.Target is of type object

            Settings.RunCount++; // Change a settings value.

            settingsReference.Target = Settings; // This call writes the updated data into FLASH.

            //Debug.Print(Settings.WelcomeMessage);
            Debug.Print("Room Number: " + Settings.RunCount.ToString());

            Thread.Sleep(2000);

            //Load The windows
            window = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Window));


            // Resize any loaded Window to the LCD's size.
            Glide.FitToScreen = true;

            // Load the Window XML string.
            //window = GlideLoader.LoadWindow(xml);

            //Activate touch 
            GlideTouch.Initialize();

            // Initialize the window.
            InitWin(window);

            // Assigning a window to MainWindow flushes it to the screen.
            // This also starts event handling on the window.
            Glide.MainWindow = window;

            Thread.Sleep(-1);
        }

        static void InitWin(Window window)
        {


            //Handler for RunCount TextBlock
            TextBlock RunCountTextBlock = (TextBlock)window.GetChildByName("RunCountTextBlock");

            RunCountTextBlock.Text = "Room Number: = " + Settings.RunCount.ToString();
            {

                // Get the Dropdown
                Dropdown dropdown = (Dropdown)window.GetChildByName("dropdown");
                dropdown.TapEvent += new OnTap(dropdown_TapEvent);
                dropdown.ValueChangedEvent += new OnValueChanged(dropdown_ValueChangedEvent);


                // Create the list that the Dropdown uses...
                list = new List(dropdown.Options, 150);
            }
        }

      /*  // Or you can provide your own options


        ArrayList options = new ArrayList()
        {
            // Each object array contains Label, Data
            new object[2] { "Room 1", 1 },
            new object[2] { "Room 2", 2 },
            new object[2] { "Room 3", 3 },
            new object[2] { "Room 4", 4 },
            new object[2] { "Room 5", 5 }
        };
        list = new List(options, 150);
        

        list.CloseEvent += new OnClose(list_CloseEvent);
    }
            
        
        */

        // When the Dropdown is tapped it will open it's list.
        static void dropdown_TapEvent(object sender)
        {
            Glide.OpenList(sender, list);

        }

        // This shows when the Dropdown's value changes.
        static void dropdown_ValueChangedEvent(object sender)
        {
            Dropdown dropdown = (Dropdown)sender;
            Debug.Print("Room Number: = " + Settings.RunCount.ToString());



        }

        static void list_CloseEvent(object sender)
        {
            Glide.CloseList();
        }


        public void SaveSettings()
        {
            // It is enough to set the Target property in order to write the data into FLASH.
            settingsReference.Target = Settings;
        }

        public void DeleteSettings()
        {
            // Data recovering and storing must be kept in pairs.
            // Calling Recover without setting Target frees the FLASH completely from this EWR.
            ExtendedWeakReference.Recover(typeof(AppSettings), 0);
        }

        public void RestoreLastSavedSettings() // Use this method to rewrite current settings using last saved data.
        {
            // First, mark the stored data as unrecovered so we can Recover them.
            settingsReference.PushBackIntoRecoverList();


            // Try to recover them, but do not create them if they do not exist.
            ExtendedWeakReference restoreReference = ExtendedWeakReference.Recover(typeof(AppSettings), 0);
            if (restoreReference != null && restoreReference.Target != null)
            {
                Settings = (AppSettings)restoreReference.Target; // If they do, use them to refresh current settings.
                restoreReference.PushBackIntoRecoverList(); // Since we found the data, we have to put them back.
            }
            else
                Debug.Print("Could not restore settings.");


            {
                Debug.Print("Rebooting...");
            }



        }
    }
}

Where should I place the

string value = "<Option Value=\"" + Setting.RunCount.ToString() + "\">Label1</Option>";

?? Thanks?

@ blue123 - That was simply provided as a general example of how you should structure variables to include program data in the XML data sheet. You will create a string, assign it the static XML data up to where you need an application variable, append the variable’s value and then continue with static data. Your data sheet will resemble the following:


string XML = "<Glide Version=\"1.0.5\"><Window Name=\"window\" Width=\"480\" Height=\"272\" BackColor=\"dce3e7\"><TextBlock Name=\"RunCountTextBlock\" X=\"100\" Y=\"160\" Width=\"120\" Height=\"32\" Alpha=\"255\" Text=\"Scroll\" TextAlign=\"Right\" TextVerticalAlign=\"Middle\" Font=\"3\" FontColor=\"000000\"/>";
            XML += "<strong>  <Dropdown Name=\"dropdown\" X=\"10\" Y=\"90\" Width=\"160\" Height=\"32\" Alpha=\"255\" Value= \"" + Settings.RunCount.ToString() + "\" Text=\"\" Font=\"4\" FontColor=\"000000\"> </strong>";
            XML += "<Option Value=\"Data0\">Label0</Option><Option Value=\"Data1\">Label1</Option><Option Value=\"Data2\">Label2</Option><Option Value=\"Data3\">Label3</Option>";
            XML += "<Option Value=\"Data4\">Label4</Option><Option Value=\"Data5\">Label5</Option><Option Value=\"Data6\">Label6</Option><Option Value=\"Data7\">Label7</Option>";
            XML += "<Option Value=\"Data8\">Label8</Option><Option Value=\"Data9\">Label9</Option></Dropdown></Window></Glide>";

Just remember to properly escape string delimiters.