我想给我的xaml添加一个变量。
我的xaml看起来像这样
<Page
x:Class="UwpTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UwpTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="using:System"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<system:String x:Key="var1">1.2</system:String>
</Page.Resources>
<Grid>
</Grid>
</Page>
运行时,我得到运行时错误。
Microsoft.UI.Xaml.Markup.ReflectionHelperException
HResult=0x80131500
Message=Error in reflection helper. Please add '<PropertyGroup><EnableTypeInfoReflection>false</EnableTypeInfoReflection></PropertyGroup>' to your project file.. Created Xaml type 'String' has a different name than requested type 'System.String'
Source=Windows
StackTrace:
at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
at UwpTest.MainPage.InitializeComponent() in D:\Dev\UwpTest\UwpTest\obj\x86\Debug\MainPage.g.i.cs:line 33
at UwpTest.MainPage..ctor() in D:\Dev\UwpTest\UwpTest\MainPage.xaml.cs:line 27
1条答案
按热度按时间w7t8yxp51#
我想在我的xaml中添加一个变量
例如,您可以将x:String作为变量添加到资源中
有关更多信息,请参阅XAML intrinsic data types