【发布时间】:2023-03-22 05:12:02
【问题描述】:
好的,我正在使用 Visual Studio 和 uwp。我创建了一个 WeatheVM,以作为资源绑定到我的页面。每次我创建资源时,它都说“无法创建 WeatheVM”我很沮丧,我不明白为什么不让我,我需要这个来访问我的属性。
<Page x:Class="uwpMVVM.View.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:uwpMVVM.View"
xmlns:vm="using:uwpMVVM.ViewModel"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<vm:WeatherVM x:Key="vm" />
</Page.Resources>
<Grid>
<AutoSuggestBox x:Name="box"
Grid.Column="1"
Margin="40"
QueryIcon="Find"
/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="53*" />
<ColumnDefinition Width="247*" />
</Grid.ColumnDefinitions>
</Grid>
</Page>
顺便说一句,我的虚拟机是一个公共类
【问题讨论】: