我有文件ResourceDictionary.xaml
<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
<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>我怎么才能用动力壳牌做这件事?
发布于 2015-04-28 11:44:11
将文件读入XML文件,更改值,然后将其保存回文件:
[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')https://stackoverflow.com/questions/29918236
复制相似问题