[英]Multiple entries in Application.Resources
<Application x:Class="Myprogram.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Myprogram.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:helper="clr-namespace:Myprogram.Helper"
StartupUri="Views\LoginView.xaml"
mc:Ignorable="d">
<Application.Resources>
<helper:MathConverter x:Key="MathConverter"/>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
Source="Themes/ExpressionLight.xaml">
</ResourceDictionary>
</Application.Resources>
</Application>
我的<Application.Resources>
元素中有2個條目。 該文件可以與其中之一正常工作,但不能同時工作。 我得到錯誤
x:key屬性為必填項
如何同時添加兩者?
您需要創建一個合並的資源字典
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Themes/ExpressionLight.xaml"/>
</ResourceDictionary.MergedDictionaries>
<helper:MathConverter x:Key="MathConverter"/>
</ResourceDictionary>
</Application.Resources>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.