dymamic text binding in a WPF TextBlock - wpf

Sorry for the noob question.... but
I have a rather large unilingual application that I have to make multilingual, meaning no resource file. I don't have the option of using the culture information but need to do it more on the fly at runtime so that the user can change languages either on startup or menu pick while in the application. I can handle that part ok. I realise there are traditional ways to set these values but I'm hoping to find a better solution.
What I'd like to be able to do is the following
First of all is this even possible? I've taken a pretty good look around and didn't really find anything close to what I'd like to do. I would even be willing create a few user controls if that was the solution. In the end I'll have to do this for buttons, labels, datagrid headers and messages(these are easy lol)
Any thoughts would be appreciated.
Thanks

Yes it is possible. Try this article: Creating an Internationalized Wizard in WPF.
Specifically look at the startup code for the application where CurrentCulture is modified for the CurrentThread.
Do not feel locked out of using per-culture resources by WPF. Different resources can be used via the "PublicResXFileCodeGenerator" as described in the article.

The MSDN Docs - CultureInfo.CurrentCulture Property may help.

Related

bind data when user controls can be switched in WP7

I just worked with C# but do not have any idea on Silverlight so I am trying to know if there is a possibility of following.
I have 2 possible layouts for my list box items. so I have created 2 different user controls. Which are completely different that I cannot comprimise and put them in a single control and disable and enable on certain condition. I assumed that this approach will delay the load (correct me if I am wrong). So I am looking for a possibility if I can switch them from xaml. I can switch the control in c# code and even populate them. But data population in c# is a pain when compared to silverlight. I am asking this question only because I want to use data binding.
Is there a way to switch them from xaml. or is there a efficient way of doing this. Even a link of any article that can help is fine.
Thanks in advance.
Maybe DataTemplateSelector will be suitable for you.
I would disagree that data population in Silverlight is a pain.
On the contrary, this is actually one of the strongest benefits with Silverlight and Xaml, because of the excellent data binding capabilities you have access to.
So if you don't already, make sure you actually are utilizing this properly.
I don't know exactly how you would like to switch between these different views, but one way would certainly to bind the visibility of your views to another element on the page that determines which of them should be visible.
That way you can do it within Xaml.

AutoComplete-ready ComboBox in Silverlight 3

Has anybody out there had a situation where you needed to implement an "editable" ComboBox in Silverlight? My client wants a ComboBox in their UI that allows the user to place focus on the selection box and start typing to automatically pull up the desired value from the available items, rather than requiring use of the drop-down list.
This feature is available, I know, in several implementations from third parties. For example, you can make this happen fairly easily with Telerik's RadControls for Silverlight. However, my client is restricted to using the Silverlight 3 Toolkit, with no third-party tools or plug-ins.
Any suggestions for a quick, down-and-dirty implementation? Any guidance or links are appreciated!
Thanks,
Jeff
Okay, we had the same problem.
We went ahead and used the AutoCompleteBox from the Silverlight 3 tookit. Their implementation has a lot of things missing that we wanted. Because of these limitations, we created our own that inherited from it. It worked great and was very simple to do. Any tutorial for making your own control that inherits from another will help you.
Have fun. Since the toolkit is open source, you can always look at the code for guidance.
You can see the samples from the toolkit here: https://www.silverlight.net/content/samples/sl3/toolkitcontrolsamples/run/default.html

XAML usage question

As far as I know, XAML is only used in WPF and Silverlight, isn't it?
Thanks.
No, it is also used in Windows Workflow Foundation:
Using Workflow Markup
XAML is also the basis for XPS.
It is also used in Office 2007+ *x formats
You can use it for whatever you like (beginning with .NET 4.0 if I'm not mistaken, didn't try it in 3.5).
However, if you do so, please also use the other good things .NET has to offer, such as "INotifyPropertyChanged" and dependency properties. Otherwise whatever you create will be a less - than - optimal solution.
There is a huge mistake I often see people make when they say, "XAML is UI markup." It's not. You can have XAML with no UI whatsoever. XAML is, in essence, an XML object graph. It is markup for creating classes. It provides the parser with instructions on how to generate instances of types and set properties on those types. This is extremely useful for creating UI in WPF and Silverlight but can also extend to sample data, view models, and other constructs. As mentioned here, it is also used in Workflow and other areas.

What is the best way of localization LOCBaml or Resx based localization?

I came through this What is the best way to localize a WPF application, sans LocBAML? . But, this didn't answer what I'm looking for.
I'm creating a CustomControl in WPF. I would like to provide localization support. The control contains, images, strings etc.,
Any help would be greatly appreciated.
Thanks
I think the document linked in this post contains a lot of information about localization in WPF. In the end, it is up to you to decide which mechanism to use.
Since you are talking about a custom control, I would consider to give it a Culture dependency property which the consumer of your control can use to specify the desired culture. This way, the consumer can use your localized control, relatively independent of the localization strategy he/she chose.
I'd suggest using Resx, try integrating into a WPF application with the TranslationByMarkupExtension example. http://www.wpftutorial.net/LocalizeMarkupExtension.html
LocBaml was a very odd thing for Microsoft to put out there and isn't better, or even complete.

Is there any way of getting a XAML Editor, either build or download?

In my current project (presentation, slide software) I need to be able to make some simple XAML, text images, movies and stuff like that.
If it were HTML I would go with fckeditor or another free editor, but what to do in XAML?
Anyone know if its possible to make one yourself (like executecommand to a IE)? or download one from anywhre on the net?
Cheers
Take a look at this question: Designing WPF Windows for Free?
The leading answer recommends Kaxaml, XAMLpad and several more options.

Resources