Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

  • HarshBardhan

    HarshBardhan

    Star

    10118 Points

    1749 Posts

    Re: Re: How to get Template field control id in silverlight datagrid.

    Jul 03, 2009 01:29 PM | LINK

     Hi Kargo,

    You can try with something like this.

    Here i have modified City;provider class only.Here Service is returning data from which property is getting populated.


    public class CityProvider
        {

            public CityProvider()
            {
                ServiceReference2.WebService1SoapClient client = new SilverlightApplication2.ServiceReference2.WebService1SoapClient();
                client.HelloWorldCompleted+=new EventHandler<SilverlightApplication2.ServiceReference2.HelloWorldCompletedEventArgs>(client_HelloWorldCompleted);

                client.HelloWorldAsync();
            }
            void client_HelloWorldCompleted(object sender, SilverlightApplication2.ServiceReference2.HelloWorldCompletedEventArgs e)
            {
                CityList = e.Result;
            }
          
            public List<string> CityList
            {
                get;
                set;

            }
        }

     

    you can access resource in codebehind also   and can set its property.

    Some thing like below mentined code.

     public Page()
            {
                InitializeComponent();
               
                this.Loaded += new RoutedEventHandler(Page_Loaded);

         
             ServiceReference2.WebService1SoapClient client = new SilverlightApplication2.ServiceReference2.WebService1SoapClient();
             client.HelloWorldCompleted += new EventHandler<SilverlightApplication2.ServiceReference2.HelloWorldCompletedEventArgs>(client_HelloWorldCompleted);

             client.HelloWorldAsync();
            }
            void client_HelloWorldCompleted(object sender, SilverlightApplication2.ServiceReference2.HelloWorldCompletedEventArgs e)
            {
                CityProvider cprovider = ((CityProvider)(this.Resources["cityProvider"]));
                cprovider.CityList = e.Result;
            }
          
     

    Mark as answer if this post answered your question.

    Harsh Bardhan