gpt4 book ai didi

c# - 命名空间前缀 "system"未定义

转载 作者:太空狗 更新时间:2023-10-30 00:24:09 29 4
gpt4 key购买 nike

我的 XAML 标记出现错误。我正在尝试将主/子数据网格绑定(bind)到数据集(数据集链接到 SQLite 数据库)。我的 XAML 是:

<Window x:Class="TabletTester7.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TabletTester7"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:System="clr-namespace:System;assembly=mscorlib"
Title="MainWindow" Height="350" Width="525">

<Window.Resources>
<ObjectDataProvider x:Key="FeaturesDataProvider"
ObjectType="{x:Type local:FeaturesDataProvider}"/>
<ObjectDataProvider x:Key="ChannelsDataProvider"
ObjectType="{x:Type local:ChannelsDataProvider}"/>

<ObjectDataProvider x:Key="Feature"
ObjectInstance="{StaticResource FeaturesDataProvider}"
MethodName="GetDefaultView"/>
<ObjectDataProvider x:Key="ChannelsByFeature"
ObjectInstance="{StaticResource ChannelsDataProvider}"
MethodName="GetChannelsByFeature">
<ObjectDataProvider.MethodParameters>
<x:Static Member="system:String.Empty"/> <!--Error here-->
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

</Window.Resources>
<Grid Margin="0,0,0,-2">

<DataGrid Name="dgFeatures" ItemsSource="{Binding Source={StaticResource Feature}}"
Margin="0,0,0,179"
AutoGenerateColumns="False"
IsSynchronizedWithCurrentItem="false"
RowEditEnding="dataGrid_RowEditEnding"
SelectedValuePath="Feature_Id"
SelectionChanged="dgFeatures_SelectionChanged"
Grid.Row="0">
<DataGrid.Columns>
<DataGridTextColumn Header="Feature ID" Binding="{Binding Feature_Id}"></DataGridTextColumn>
<DataGridTextColumn Header="Feature ID" Binding="{Binding Feature_Name}"></DataGridTextColumn>
<DataGridTemplateColumn Header="Date">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding Date}" BorderThickness="0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

</DataGrid.Columns>
</DataGrid>
<DataGrid Name="dhChannel"
ItemsSource="{Binding Source={StaticResource ChannelsByFeature}}"
Margin="0,148,0,0"
Grid.Row="1"
AutoGenerateColumns="False"
>
<DataGrid.Columns>
<DataGridTextColumn Header="Channel Path" Binding="{Binding Channel_Path}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>


</Grid>
</Window>

我尝试调用的方法的签名为

public DataView GetChannelsByFeature(string featureId)

在线<x:Static Member="system:String.Empty"/>我收到两个错误:

The namespace prefix "system" is not defined.

String is not supported in a Windows Presentation Foundation (WPF) project.

如何定义这个方法参数?

最佳答案

在使用前必须先声明系统命名空间。

<ObjectDataProvider x:Key="ChannelsByFeature"
xmlns:system="clr-namespace:System;assembly=mscorlib" <!-- HERE -->
ObjectInstance="{StaticResource ChannelsDataProvider}"
MethodName="GetChannelsByFeature">
<ObjectDataProvider.MethodParameters>
<x:Static Member="system:String.Empty"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>

关于c# - 命名空间前缀 "system"未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28890180/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com