Silverlight动态载入调用XAML资源

时间:2014-04-29 15:59:30   收藏:0   阅读:434
 

     以多语言为例子:

    ResourceDictionary resourceDictionary = new ResourceDictionary(); //新建资源集合

            var culture = CultureInfo.CurrentCulture;//获取本地Culture

            if (culture.Name != "zh-CN")

            {

                Application.LoadComponent(resourceDictionary, new Uri("/ETiger_MarketTrack;component/Language/Chinese.xaml", UriKind.Relative));

            }

            else

            {

                Application.LoadComponent(resourceDictionary, new Uri("/ETiger_MarketTrack;component/Language/English.xaml", UriKind.Relative));

            }

    //将资源集合添加到AppResource中,注意这些代码必须在使用这些资源的控件初始化之前

            Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);

Silverlight动态载入调用XAML资源,码迷,mamicode.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!