|
using System;
using System.Linq;
using System.Windows;
using System.Threading;
using System.Globalization;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using WPF_Globalization.ViewModel;
namespace WPF_Globalization
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
SetImportCatalog();
SetLanguage();
}
private void SetImportCatalog()
{
try
{
string path = AppDomain.CurrentDomain.BaseDirectory;
DirectoryCatalog catalog = new DirectoryCatalog(path);
CompositionContainer container = new CompositionContainer(catalog);
container.ComposeParts(BaseModel.Instance.ImportCatalog);
}
catch (Exception ex)
{
}
}
private void SetLanguage()
{
try
{
string cultureCode = "en-US";
CultureInfo cultureInfo = new CultureInfo(cultureCode);
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
var dictionary = (from d in BaseModel.Instance.ImportCatalog.ResourceDictionaryList
where d.Metadata.ContainsKey("Culture")
&& d.Metadata["Culture"].ToString().Equals(cultureCode)
select d).FirstOrDefault();
if (dictionary != null && dictionary.Value != null)
{
this.Resources.MergedDictionaries.Add(dictionary.Value);
}
}
catch (Exception ex)
{
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Having 9+ years of experience in Microsoft.Net Technology.
Experience in developing applications on Microsoft .NET Platform ( Asp.Net, WPF, Silverlight, Windows Phone 7/8).
Experience and knowledge of software design methodologies (Agile), object oriented design, and software design patterns (MVVM).
Experience in Developing android mobile application using Xamarin (mono for android) framework.
http://hirenkhirsaria.blogspot.com/