首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用ResourceDictionary更改和保存XAML ResourceDictionary

用ResourceDictionary更改和保存XAML ResourceDictionary
EN

Stack Overflow用户
提问于 2015-04-28 11:29:36
回答 1查看 577关注 0票数 1

我有文件ResourceDictionary.xaml

代码语言:javascript
复制
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp">
    <Style x:Key="GridStyle" TargetType="Grid">
        <Setter Property="Background" Value="Red"></Setter>
    </Style>
    <x:String x:Key="AppTitle">My App</x:String>
</ResourceDictionary>

我要更改背景属性和AppTitle。

输出ResourceDictionary2.xaml

代码语言:javascript
复制
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp">
    <Style x:Key="GridStyle" TargetType="Grid">
        <Setter Property="Background" Value="Green"></Setter>
    </Style>
    <x:String x:Key="AppTitle">My App 2</x:String>
</ResourceDictionary>

我怎么才能用动力壳牌做这件事?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-28 11:44:11

将文件读入XML文件,更改值,然后将其保存回文件:

代码语言:javascript
复制
[xml]$xml = Get-Content 'C:\path\to\ResourceDictionary.xaml'

$xml.ResourceDictionary.Style.Setter.Value = 'Green'
$xml.ResourceDictionary.'#text' = 'My App 2'

$xml.Save('C:\path\to\Output ResourceDictionary2.xaml')
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29918236

复制
相关文章

相似问题

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