WPF: Customized regional settings - wpf

I just found out today that WPF will ignore CultureInfo.CurrentCulture and always use en-US. I have also found a wonderful answer here. Everything worked fine until one of the users customized the regional settings to change the currency symbol (here in the Philippines you could write Php and P and most people prefer P, the default setting is Php). The application doesn't seem to pick this up. Is there any way around this?

I recently had to check for the current country setup for my C# WPF application.
I used CurrentCulture and not CurrentUICulture (which picked up EN-US for me too).
Also, I'm not sure this will help- but I found out I was testing this functionality in the wrong place.
To change the country of your app for testing go to:
“Control Panel->Clock, Language, and Region” select the “Region and Language” button, a window will pop up, go to the format tab, change the country in the format listbox.
Once I did that CurrentCulture worked fine.

Well after a week's research of two people, I think there is currently no way of doing this using the Globalization classes.
CurrentUICulture and other related classes contain the default formats/settings for the selected Language but not the customized settings.
One way to do this is by reading the values straight from the registry key, HKCU\Control Panel\International.

Yes, there is a way to make WPF use customized regional settings, but you need to force all bindings to use CultureInfo.CurrentCulture. See this post for examples.

Related

How to quickly find a property of WinForms control?

Recently I started a project in WinForms. I'm coming from WPF background and I find some things new to me. For example every time I want to change a property of WinForms control I have to scroll up and down to find it.
It drives me mad. I would rather type first few letters of looked up property and edit it in a couple of seconds. Is there a way to speed up this annoying process?
There is no easy way to filter properties of control. I know how you feel, as I switch between WPF and WinForms from project to project. But you can always either Categorize them or sort them alphabetically... I am sure you'll get used to it eventually, but you have to understand though, Windows Forms are not as "innovative" as WPF is. Therefore you'll see some things are rather more "traditional" than WPF in WinForms! Sorry mate :)
There is a VS Extension called RapidDesign. It is a payed project but I think it's worth the price. It does exactly what you need and even more. (Note!!! I am not connected in anyway with the author/company that develops this product)
https://visualstudiogallery.msdn.microsoft.com/c820e3a0-add2-4a43-943c-029e296ab00d
You can download the extension directly from VisualStudio galery or you can install it from inside VS by going to Tools->Extensions And Updates...->Online->and search for RapidDesign

dymamic text binding in a WPF TextBlock

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.

WPF - Why doesn't Microsoft supply a decent set of most-used controls ?

I've been playing with WPF for some months now, and I quite like it.
But one of the things I don't get is why MS doesn't put a little more effort in helping developers by supplying basic controls, and I need to get this off my chest :)
For example, I figure most applications somewhere will need to let you edit some properties - for configuration or whatever.
What would be the most used types in a proprety-grid editor ?
text
numbers (byte, float/double, int, etc)
colors
....etc.
So why isn't there even something as simple as a control to edit numbers ? Like a generic NumericUpDown control that allows you to type in numbers (no text, no pasting invalid input) or spin them up/down according to some given rules (decimal, floating point, min/maxvalue) ?
Why isn't there a generic colorpicker, so people get the same user-experience in every application ?
Why isn't there a standard implementation of a SearchTextBox, a BreadCrumb-control, or all these other standard control types users have gotten accustomed to the last 10 years ?
(..but at least they DID have the time to implement a generic splashscreen - because everyone knows that greatly increases user-productivity....)
The well-known ideal is always to give people the same user-experience over different applications. So even if some of those controls would be easy to make - it would be preferred to have one version over different applications.
I see people all over the internet trying to do the same stuff over and over again.
Okay, so MS started a WPF Toolkit project on Codeplex that tries to implement some controls, but only did so half-heartedly and is completely dead by now (last update of the roadmap dates back to Mar 21 2009).
The result of this is that a lot of people starting a WPF-project end up spending a lot of time on trying to figure out how to create some generic controls and get really frustrated.
Wasn't the mantra "Developers, developers, developers!" ..?
/Rant
Because its ridiculously easy to make these in WPF. With WPF and silverlight microsoft's focus is on a core framework that makes many tasks (such as stylable controls) dead simple. Tools are more important than prebuilt controls. They are focusing on the NEXT thing rather than a better Winforms.
I think Microsoft - and some people responding here - are forgetting about the most important part of this post :
"The well-known ideal is always to give people the same user-experience over different applications. So even if some of those controls would be easy to make - it would be preferred to have one version over different applications"
Just Google Image Search on "WPF Color Picker" ( http://www.google.nl/images?q=wpf+color+picker ) and you'll see this idea go down the drain.
That's exactly what i thought at the beginning with WPF..
But afterall, a NumericUpDown is easily created with a cutom usercontrol, same for all the controls you will ever need, you can create it by yourself in (almost) no time, or grab some implementation googling around, and then you can still customize
I think they provided the very basic implementations for the UI elements and leaved all the custom stuff to developers and who need custom stuff, if they would have done a generic color picker, maybe it wouldn't have had all the functionalities that anyone would ever need
There are a lot of 3rd party vendors out there that provide powerful custom controls (editor, navigation, grids, menus, property grids, ...).
It's - in general - cheaper to buy from them than to rewrite your own (when it fits your need of course).
Historically, Microsoft has always encouraged a rich "component-based" eco-system around what they provider out-of-the-box features. This has been true from the beginning of component programming (VBX, OCX, ...) with Microsoft technology. This is arguable, but that's the strategy :-)

Is a drag-over checkbox list useful?

A while ago I created a drag-over check box list which allows you to check many check boxes in a single gesture. Do you think it is viable and usable on the web where people might not know how to use it. The default behaviour still works for the individual check boxes.
1 - The idea
The idea is nice and can probably be used in professional applications where you have direct contact with users and can explain them how things work, but not necessarily on public websites where users don't want to RTFM and are just looking for familiar behaviours. Unless it was just a sample exercise or a control meant to be included it in a control pack, it violates the YAGNI principle ;)
2 - The implementation
You certainly noticed that the implementation is buggy (at least on IE7 and FF3.1B2). Sometimes, a gesture above all checkboxes will select all of them but one or two. Moving the mouse over the div's above or below the list will stop the drag (I know it's a "feature", but it's not very user friendly). I Checked the source code and to be honnest, while it looks pretty neat, I just didn't want to deal with it because it is plain javascript. Don't you know that...
3 - Possible improvements
...you can write less and do more with a javascript library, typically jQuery. I would completely rewrite this control as a jQuery plugin. It will provide you with a lot of tools to make your code much easier to write, maintain and extend. Just try it, you'll love it. This is from a technical point of view. From a user point of view, try to make you control as familiar as possible, like what Angela suggested, windows explorer : a nice selection rectangle, the ability to use shit + click, or something like that. Finally, remember that for many windows checklistbox users, "selected" and "checked" are two different things.
The demo definitely needs a few enhancements to make it even a little bit useful (although I am not sure if it would be enough):
Allow the dragging to start somewhere that is not a check box.
Allow selection by dragging over the labels as well.
This problem seems similar to the action of selecting multiple files in a file explorer like Windows Explorer. Maybe it can work like the action of selecting multiple files by dragging a rectangle shape around the items to be selected (select one corner, drag to the other corner)? This has the advantage of being similar to an interface element that people may already be familiar with.
For some reason I can't open your link (it says my ip address was blocked). But I think what you're looking for is what I already did in jquery, I uploaded a plugin which I basically ported from crossbrowser.com's dragcheck functionality, it was to be found at http://plugins.jquery.com/project/dragCheck but currently the jquery plugin site is being revamped and my plugin has disappeared. I'm trying to see if they're going to put it back up or if I have to create a new project again...
Anyways until we get that worked out you can see a demo here: http://jsbin.com/ibihi

Where can I find an AutoComplete TextBox code sample for Silverlight?

I've searched around for a while today, but I haven't been able to come up with an AutoComplete TextBox code sample for Silverlight 2 Beta 2. The most promising reference was found on nikhilk.net but the online demo doesn't currently render and after downloading a getting the code to compile with Beta 2, I couldn't get the Silverlight plugin it to render either. I think it is fair to say it is a compatibility issue, but I'm not sure. Does anyone have any alternate sample code or implementation suggestions?
You may want to take a look at my blog: http://weblogs.manas.com.ar/ary/2008/09/26/autocomplete-in-silverlight/
You simply write in your XAML:
manas:Autocomplete.Suggest="DoSuggest"
and then in the class file, you need to implement that method, which report suggestions to a delegate. The options can be hardcoded, requested to a web service, or whaterver.
Take a look at the combobox(very close to a autocomplete text box) at worksight's blog Silverlight ComboBox
There is also another good example here:
http://silvermail.com.au
This is a Silverlight based mail client that looks a little like Outlook. When I go to send mail and start typing in the "To" text box, an auto-complete pops up and populates the control for me based on values in a list... I think it automatically stores the addresses in isolated storage, but that's just a guess.
This is a really handy tool for checking mail while away from my home PC... at work for example... and it is loaded with impressive Silverlight functionality.
S.

Resources