Sunday, March 8, 2009

Adding RTL Support to Silverlight Using SilverlightRTL Library – Part 1

In the previous post, options to display Arabic text with Silverlight has been explored. In this post we will explore how to use the Open Source SilverlightRTL library available from http://www.codeplex.com/silverlightRTL to add RTL support for Silverlight Applications.

Using SilverlightRTL From Visual Studio
First you will need to download the bits from CodePlex site, you can either download the latest release from http://silverlightrtl.codeplex.com/Release/ProjectReleases.aspx or if you want the most recent update, you can download the source code from http://silverlightrtl.codeplex.com/SourceControl/ListDownloadableCommits.aspx. I recommend download the source code, so you get the latest updates, and you can debug into the source code if you happen to face any problem.
Now add reference to the BidiControls assembly or the project if you are using the source code directly from your project.
The next step is to add a namespace reference to your XAML file. Please note that you need to compile the project first if you are using project reference or intellisense to work. The XMLNS declaration should look like the following snippet:

   1: clr-namespace:System.Windows.BidiControls;assembly=BidiControls




And Visual Studio screen should look like the following figure:

namespace



Now you can declare a BIDI control by prefixing the control with bidi: namespace, for example:





   1: <bidi:TextBlock Text="أهلا عالم" FontSize="18" />




Using SilverlightRTL from Blend

Firstyou will need to add reference to the BidiControls.dll assembly or the System.Windows.BidiControls project. To add a control You can open the “Asset Library” at the bottom of the Toolbox. Select “Custom Controls” tab. You should find the BIDI controls available. You can search for a specific control using search box. The following screenshot shows that



blend_add



Please stay tuned. I will post more about the specific controls implemented, how you can use and style them, and how the controls were implemented.

7 comments:

Anonymous said...

thanks for your silverlight rtl notes

reza said...

thanks for your silverlight rtl project i use it in persian text and it well works but your textbox control is so buggy special this issue in this link http://silverlightrtl.codeplex.com/WorkItem/View.aspx?WorkItemId=7223

Mohammad Heskol said...

Thanks for your work in the library and for this article. I needed to add Arabic language support to Silverlight and your solution seems to do exactly that.

Anonymous said...

thanks for your work.I need to implement ummulqura calander(AR-SA)

mabdulhadi said...

Hi,
Silverlight Toolkit contains a global calender control which converts Georgian Calender to Hijri Calender perfectly. The only problem with this calender is that it does not support BiDi.
I noticed that there is a date picker and calender control included in Silverlight RTL project, but I can't figure out how to change it from Georgian to Hijri.Please help.
Thank you

Anonymous said...

Yup, works for me too. Thanx bro

s.c.vinod said...

Hi,
Thanks for the post. I have a problem when I type in Arabic in a SilverLight textBox it is displaying the letters in English only and not in Arabic. Can you pls give me a solution. Thank you.