小编Zad*_*xmi的帖子

无法转换 MS.Internal.NamedObject

<DataGrid x:Name="DisplayRecipeGrid" AutoGenerateColumns="False" CanUserAddRows="false" ItemsSource="{Binding ModuleRecipeCatalog}"   VerticalContentAlignment="Center" IsReadOnly="True">
    <!---->
                                            <DataGrid.RowStyle>
                                                <Style TargetType="{x:Type DataGridRow}">
                                                    <EventSetter Event="MouseDoubleClick" Handler="EditRecipe_Executed"></EventSetter>
                                                </Style>
                                            </DataGrid.RowStyle>
                                            <DataGrid.Columns>
            <DataGrid x:Name="DisplayRecipeGrid" AutoGenerateColumns="False" CanUserAddRows="false" ItemsSource="{Binding ModuleRecipeCatalog}"   VerticalContentAlignment="Center" IsReadOnly="True"><!---->
    <DataGrid.RowStyle>
        <Style TargetType="{x:Type DataGridRow}">
            <EventSetter Event="MouseDoubleClick" Handler="EditRecipe_Executed"></EventSetter>
        </Style>
    </DataGrid.RowStyle>
    </DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)

使用后CanUserAddRows="false",当我操作数据时。

最终出现错误,指出无法投射MS.Internal.NamedObject

尝试使用以下方法,它有效:

if (obj.GetType().ToString() != "MS.Internal.NamedObject")
    return this.Equals(obj as RecipeBase);
else
    return false;
Run Code Online (Sandbox Code Playgroud)

任何人都可以有任何其他方法吗?

c# data-binding wpf

2
推荐指数
1
解决办法
2302
查看次数

System.UriFormatException:无效的 URI:指定的端口无效。在 c# 中

当我尝试进行单元测试时,

我最终出现错误,指出“System.UriFormatException:无效的 URI:指定的端口无效。” 显示错误的代码是,

  public Dictionary<SensorMode, Uri> ImageSrc = new Dictionary<SensorMode, Uri>()
        {
            {SensorMode.f, new Uri("pack://application:,,,/Resources/TS.png") },//towards to sensor image
            {SensorMode.b, new Uri("pack://application:,,,/Resources/AS.png") },//away from the sensor image
            {SensorMode.c, new Uri("pack://application:,,,/Resources/F.png") },//fast moving image
            {SensorMode.p, new Uri("pack://application:,,,/Resources/S.png") },//slow moving image
            {SensorMode.x, new Uri("pack://application:,,,/Resources/fail.png")}//fail image 
        };
Run Code Online (Sandbox Code Playgroud)

谁能帮我解决这个问题。

c# nunit unit-testing

1
推荐指数
1
解决办法
2236
查看次数

标签 统计

c# ×2

data-binding ×1

nunit ×1

unit-testing ×1

wpf ×1