iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Dear Sir/Madam,
I'm experimenting with the ClientUI Ribbon Application sample and I really do like how it was handled the creation of the Ribbon using the RibbonFactory class and the xml data located in the Assets folder.
What I'm curious is, how can I for example use Binding in the Text and Header properties of the controls.
What I'm actually trying to do is to create something like this in the RibbonOverviewData.xml
<RibbonTabGroup Header="{Binding Resource.CreateNewHeader, Source={StaticResource ApplicationResource}}" ...>
And in the RibbonFactory class create the proper bindings.
In the xaml is easy as pie, but in code I'm a bit lost.
Would you mind to give me a hand with this?
Sorry for the delay in sending this.
I created a simple WPF project of UXRibbon based on Intersoft ClientUI Ribbon Application project template. Within this project, I use the ClientUI Localization Manager to change the language.
Below is the quick review about the sample project.
This project is created using Intersoft ClientUI Ribbon Application project template.
A RibbonTabGroup, called “TestGroup”, is added into the RibbonOverviewData.xml file. TestGroup has four RibbonButton: English; Germany; France; and Spain. When user clicks Germany RibbonButton, the TestGroup’s Header is changed into Germany at runtime.
For more information about the ClientUI Localization Manager, please check the ClientUI Documentation under Localization Overview topic. I also added parser which handles the Binding on Header property.
Please have the sample evaluated on your end and let us know whether it helps or not.
Edited on February 13, 2013 10:30 PMReason: Forget to attach sample project
I use the following approach to implement localization on the UXRibbonToolTipService.
Bind TooltipContent (also applicable for TooltipHeader or TooltipFooter) to the localized resource in the xml file.
... <RibbonButton Content="New Contact" MinimumSize="Medium" TooltipHeader="New Item" TooltipContent="{Binding Localization.Resource.TodayText}" TooltipImagePath="/Assets/Images/customers.png" KeyTipAccessText="N" Icon="/Assets/Images/Ribbon/Contacts/32/new_contact.png" LargeIcon="/Assets/Images/Ribbon/Contacts/32/new_contact.png" /> ...
Modify the Tooltip parser method to handle the binding.
private static void CreateRibbonTooltip(UIElement element, XElement x, DependencyProperty property) { string content = ParseAttributeToString(x.Attribute("TooltipContent")); if (content.StartsWith("{Binding")) { Char[] splitIndicator = { ' ' }; string[] splits = content.Substring(1, content.Length - 2).Split(splitIndicator); BindingOperations.SetBinding(element, UXRibbonToolTipService.ContentProperty, new Binding(splits.ElementAt(1))); } else { if (content != null && content.Length > 0) UXRibbonToolTipService.SetContent(element, content); } }
I have tested this solution on my local end. Please let me know your feedback whether this helps or not.
I’m sorry for the delay in sending this.
In order to use Binding in the Text and Header properties we need to add parser which parse string (in xml data) into binding. The following snippet code shows the implementation of such parser for Command property.
internal static void CreateCommandProperty(XElement x, FrameworkElement element, DependencyProperty property) { string commandName = ParseAttributeToString(x.Attribute("Command")); if (commandName.Length > 0) { if (commandName.StartsWith("{Binding") && commandName.Length >= 2) { Char[] splitIndicator = { ',' }; string[] splits = commandName.Substring(1, commandName.Length - 2).Split(splitIndicator); Binding binding = null; for (int i = 0; i < splits.Count(); i++) { string str = splits.ElementAt(i); if (str.StartsWith("Binding")) { string check = "Binding "; str = str.Substring(check.Length, str.Length - check.Length); binding = new Binding(str); } else if (str.StartsWith("Mode")) { string check = "Mode="; str = str.Substring(check.Length, str.Length - check.Length); if (str.Equals("TwoWay")) binding.Mode = BindingMode.TwoWay; else if (str.Equals("OneWay")) binding.Mode = BindingMode.OneWay; else if (str.Equals("OneTime")) binding.Mode = BindingMode.OneTime; } else if (str.StartsWith("stringFormat")) { string check = "stringFormat="; str = str.Substring(check.Length, str.Length - check.Length); binding.StringFormat = str; } } if (binding != null) { element.SetBinding(property, binding); element.DataContext = _context; } } else { RibbonCommandConverter commandConverter = new RibbonCommandConverter(); if (element is ISButton) { ISButton btn = element as ISButton; object command = commandConverter.ConvertFromString(commandName); ICommand iCommand = command != null ? command as ICommand : null; if (iCommand != null) { if (btn != null) btn.Command = iCommand; } } } } }
The above code can be found in RibbonFactory.cs file (line 848).
Hope this helps.
binding.Source = new ClientUI_Ribbon_Application.Resources.AppResource().Resource;
I’ll need more time to prepare a simple sample of WebRibbon with localization and will update this thread with any news regarding the progress of the sample.
Be right back.
Thanks a lot Yudi, but you forgot to attach the sample... ;)
Edit:
I've tested it and it works! However, I'm wondering how to implement it with the UXRibbonToolTipService SetHeader(), SetContent() and SetFooter().
Thank you for the prompt reply and glad to hear that the sent sample helps.
About the question: how to implement it with the UXRibbonToolTipService SetHeader(), SetContent(), and SetFooter(), could you please let us know whether this related with the Binding in the RibbonFactory or to apply ClientUI Localization over the UXRibbonToolTipService?
Sure,
I meant to the RibbonOverviewData.xml, same as with the sample provided.
Let me further explain, in the xml file, you can set the TooltipHeader property and so on. Like for example TooltipHeader=¨Sample¨. But, I see in the RibbonFactory that the Tooltip is implemented using the UXRibbonToolTipService.SetHeader().. How could I achieve the same Localization functionality like shown in your sample (using {Binding ...})?
Or is this implemented in a different way?
Thanks in advance!
Dave
Glad to hear that the snippet code helps.
Should you need further assistance or run into any problems regarding our controls, feel free to post it into our community site. We would be happy to assist you again.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname