Instant Chat in WPF part 2

Multi languages support
To support multi languages I've used xaml resourcedictionaries files per language.
All controls with a text/content propertie bind to this dictionaries in the same manner as
with the Controllers, take a look at part 1.
Every content propertie has an unique name and these names are equal in both dictionaries.
Of course only the text itself differs per desired language.
Here below a example of the DutchDictionary.xaml:

.

Example of the binding to a content property of a label:
<Label FontFamily="Verdana"
       
Grid.Row="0" Grid.Column="0" 
       FontSize="15" 
       Content="{DynamicResource IPAddress}" />

The change of the text in the content properties of the controls isn't changed by 
the selection changed event, but through the property Languages in the Configuration
Controller from where the language combobox gets his binding on the ItemSource of the combobox.
This property fires an property changed event in his setter that then on his turn calls a method,
this method takes care of swapping the dictionary resource.
The property looks   like this:
public ObservableCollection<string> Languages{
get { languages = LanguageUsed(MainUser.Language); return languages ; }

set { languages = value; OnPropertyChanged(
                          
new PropertyChangedEventArgs("Languages")); }
}

The binding in the language combobox  is done like this:
<ComboBox Name="LanguageCmb"
          ItemsSource="{Binding Path=Languages, Mode=TwoWay}"
         
SelectedItem="{Binding Path=MainUser.Language, Mode=TwoWay}"

By binding the SelectedItem to the Mainuser you can see that even the language in the 
combox itself has changed. The SelectionChanged event is only used to take care of changing
the ItemSource of the combobox itself after the dictionary has changed, because this is
another language so it has to be adjusted so the correct language that's selected.
 

<Previous>

-December 2018+
SMTWTFS
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345
  • RSS
  • Add To My MSN
  • Add To Windows Live
  • Add To My Yahoo
  • Add To Google

Statistics

  • Entries (1)
  • Comments (0)

Archives


Leave your comments here below 

Saturday, May 28, 2011 10:50:00 AM
Site Map | Printable View | © 2010 - 2018 LeBroITSolutions | HTML 5 | CSS