首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用xamlreader加载样式

如何使用xamlreader加载样式
EN

Stack Overflow用户
提问于 2013-08-22 09:54:55
回答 1查看 571关注 0票数 1

如何使用XamlReader.Load()从xaml下面加载样式

代码语言:javascript
复制
<Window
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
        xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
>
<ResourceDictionary>
        <Style x:Key="LastRowHighlighted"
        BasedOn="{StaticResource {dxgt:GridRowThemeKey ResourceKey=RowStyle}}"
               TargetType="{x:Type dxg:GridRowContent}">
        </Style>
</ResourceDictionary>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-22 12:58:35

试着做这样的事情:

代码语言:javascript
复制
public void LoadStyle(string fileName)
{
    if (File.Exists(fileName))
    {
        try
        {
            using (FileStream fileStream = new FileStream(fileName, FileMode.Open, 
FileAccess.Read, FileShare.Read))
            {
                ResourceDictionary resourceDictionary = (ResourceDictionary)XamlReader.
Load(fileStream);
                Resources.MergedDictionaries.Clear(); // optional
                Resources.MergedDictionaries.Add(resourceDictionary);
            }
        }
        catch { }
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18377165

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档