輸入在https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.combobox?view=netframework-4.8上找到的一些 XAML 代碼時, src :會引發錯誤。有誰知道為什么或者有解決方法嗎?<Grid.Resources>
<src:IEvents x:Key="myIEvents"/>
</Grid.Resources>Visual Studio 錯誤:XDG0006 未定義命名空間前綴“src”。注意:我修改了示例,將 StackPanel 替換為 Grid。這是更新后的 XAML 代碼片段:<Window x:Class="Task_Logger.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:src="clr-namespace:Task_Logger" mc:Ignorable="d" Title="Idle Time Category" Height="246" Width="376"> <Grid> <Grid.Resources> <src:IEvents x:Key="myIEvents"/> </Grid.Resources> <ComboBox ItemsSource="{StaticResource myIEvents}" HorizontalAlignment="Left" Height="37" Margin="31,20,0,0" VerticalAlignment="Top" Width="311" Name="comboBox1" /> <TextBlock Text="{Binding ElementName=comboBox1, Path=SelectedItem}"/>這是 .cs 文件中的類namespace Task_Logger class iEvents : ObservableCollection<string> { public iEvents() { Add("Clog -- Resin Pot Valves"); Add("Clog -- MVP Valves"); . .
未找到命名空間前綴 src
慕田峪9158850
2023-07-22 18:28:50