15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

localization with WPf ❘ 593<br />

<br />

<br />

FoCalizaTion WiTh WPf<br />

Visual Studio 2010 still does not have great support<br />

for the localization of WPF applications. However,<br />

you do not have to wait until the next version to<br />

localize your WPF application. WPF has localization<br />

support built-in. With WPF, you need to decide<br />

between different options: You can use .<strong>NET</strong><br />

resources similar to what you’ve done with Windows<br />

Forms <strong>and</strong> ASP.<strong>NET</strong> applications, but you can also<br />

use an XAML (XML for Applications Markup<br />

Language) resource dictionary.<br />

figure 22-14<br />

These options are discussed next. You can read more<br />

about WPF <strong>and</strong> XAML in Chapters 35, “Core WPF,” <strong>and</strong> 36, “Business Applications with WPF.”<br />

To demonstrate the use of resources with a WPF application, create a simple WPF application containing<br />

just one button, as shown in Figure 22-15.<br />

figure 22-15<br />

The XAML code for this application is shown here:<br />

<br />

<br />

<br />

<br />

<br />

code snippet WPFApplicationUsingResources/MainWindow.xaml<br />

With the h<strong>and</strong>ler code for the Click event of the button, just a message box containing a sample message<br />

pops up:<br />

private void Button_Click(object sender, RoutedEventArgs e)<br />

{<br />

MessageBox.Show("English Message");<br />

}<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!