.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Silverlight >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Custom Markup Extensions in Silverlight 5 - Part 2

Posted By:Mahadesh Mahalingappa       Posted Date: August 19, 2011    Points: 200    Category: Silverlight    URL: http://www.dotnetspark.com  

In this article we are going to continue to learn about the Custom Markup Extensions in Silverlight 5
 

In this article we are going to continue to learn about the Custom Markup Extensions in Silverlight 5 .
 
In this post we will see how we can pass the parameters using Custom Markup Extensions .
 
Now that we have a understanding of how Custom Markup Extensions work in Silverlight lets quickly get into the code .
 
I modify my class FirstCME as shown as below :

public class FirstCME : IMarkupExtension
{
    public object value1 { get; set; }

    public object value2 { get; set; }



    public string ProvideValue(IServiceProvider serviceProvider)
    {
        double _val1 = Convert.ToDouble(value1);
        double _val2 = Convert.ToDouble(value2);

        return (_val1 + _val2).ToString();
    }
}

  
Go ahead and modify the xaml to pass the value to the parameters . It would look like below :


  
   
   
   
 

Lets give it a run and see the output :
 

  
The above xaml code could be modified as shown below : It would still work the same way . Here we pass the parameters in a Angular Bracket < > Format .
 


Lets now give it a run :
 

 
In the next post on Custom Markup Extensions we will see what are the advantages of Custom Markup Extensions .

Thanks . Happy Coding

 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend