小编Jua*_*mez的帖子

默认值类型与属性的类型不匹配

我有这门课

public class Tooth
{
    public string Id {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

而这个custrom控制

public partial class ToothUI : UserControl
{
    public ToothUI()
    {
        InitializeComponent();
    }

    public Tooth Tooth
    {
        get { return (Tooth)GetValue(ToothProperty); }
        set
        {
            SetValue(ToothProperty, value);
            NombrePieza.Text =   value.Id.Replace("_",String.Empty);
        }
    }
    public static readonly DependencyProperty ToothProperty =
        DependencyProperty.Register("Tooth", typeof(Tooth), typeof(ToothUI), new PropertyMetadata(0)); 

}
Run Code Online (Sandbox Code Playgroud)

我的问题是在Add Tooth依赖项属性之后,发生此错误

默认值类型与属性的类型不匹配

这个错误究竟是什么意思?目前设置此方法的方式是什么DP

c# wpf wpf-controls

71
推荐指数
2
解决办法
2万
查看次数

AsNoTracking()和Include

我有一个Linq查询,用于获取实体及其某些导航属性.

context.MyEntity
    .AsNoTracking()
    .Include(i=> i.Nav1)
    .Include(i=> i.Nav2)
    .Where(x=> x.Prop1==1)
    .FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

我的问题是:

以上查询是否足以不跟踪MyEntity导航属性NAv1和/ Nav2或我必须AsNoTracking为每个导航属性添加?

像这样:  

context.MyEntity
    .AsNoTracking()
    .Include(i=> i.Nav1)
    .AsNoTracking()
    .Include(i=> i.Nav2)
    .AsNoTracking()
    .Where(x=> x.Prop1==1)
    .FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework

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

c#如何获取CallerMember的类型名称

我上了这堂课

public class fooBase
{
    public List<MethodsWithCustAttribute> MethodsList;
    public bool fooMethod([CallerMemberName]string membername =""))
    {
        //This returns a value depending of type and method 
    } 
    public void GetMethods()
    {
        // Here populate MethodsList using reflection
    }
}
Run Code Online (Sandbox Code Playgroud)

而这个属性类

// This attribute get from a database some things, then fooMethod check this attribute members 
public class CustomAttribute
{
    public string fullMethodPath;
    public bool someThing ; 
    public bool CustomAttribute([CallerMemberName]string membername ="")
    {
        fullMethodPath = **DerivedType** + membername 
        //  I need here to get …
Run Code Online (Sandbox Code Playgroud)

c#

19
推荐指数
3
解决办法
2万
查看次数

绑定到WPF DataGrid时,此视图不允许使用DataGrid版本的"EditItem"

我至少已经阅读了4个小时,并且似乎是列表类型,但我有一个情况:

具有集合属性的ObservableCollection.

我定义了第一个DataGrid,并在该部分中

<DataGrid.RowDetailsTemplate>
    <DataTemplate>
        <!-- second Datagrid here, binding to Level2 property of my Observable collection -->
    </DataTemplate>
<DataGrid.RowDetailsTemplate>
Run Code Online (Sandbox Code Playgroud)

一切顺利,屏幕上的所有内容都如我所料......但是:

  1. 如果尝试修改DataGrid1单元格,它允许我.
  2. 如果尝试修改DataGrid2单元格,它会抛出这个异常 'EditItem' is not allowed for this view

我错过了什么?

这是我的模特:

public partial class Level1
{
    public Level1()
    {
        this.Level2 = new HashSet<Level2>();
    }

    public decimal IdLevel1 { get; set; }
    public decimal IdLevel2 { get; set; }
    public string StrDescripcionTipoAsociado {get;set;}

    public virtual Level2 Level2{ get; set; }
}

public partial class Level2
{
    public decimal IdLevel1 { …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml datagrid

18
推荐指数
5
解决办法
3万
查看次数

将Datagrid.SelectedItems集合转换为List <T>

我有这样的课

public class Foo
{
    public string prop1 {get;set;}
    public string prop1 {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

和一个带有a的视图模型List<Foo>,这个列表被用作Bind一个DataGrid,然后在代码隐藏中我需要获取 Datagrid.SelectedItems集合并将其转换为List<Foo>

我尝试过的事情:

List<Foo> SelectedItemsList= (List<Foo>)DataGrid.SelectedItems;
// OR
object p = DataGrid.SelectedItems;
List<Foo> SelectedItemsList= ((IList)p).Cast<Foo>().ToList();
Run Code Online (Sandbox Code Playgroud)

所有这些方式编译但在运行时抛出异常.

施放它的正确方法是什么?

注意:基本类型DataGrid是这ObservableCollection是否有所不同?

c# wpf datagrid casting wpfdatagrid

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

TF30172:您没有权限

我安装了tfs服务器,它允许我连接,但是当尝试创建团队项目时,它会显示此消息.

TF30172: You do not have permission to create a new team project.
Run Code Online (Sandbox Code Playgroud)

我目前所有的许可都已确定,或至少我认为如此.

我还能检查什么?

tfs tfs2010 tfs2012

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

如何将Intellisense描述添加到枚举成员c#

我有这个枚举:

/// <summary>
/// Accoun types enumeration
/// </summary>
public enum AcoountTypeTransaction
{
    [Description("Account type debit")]
    Debit = 0,
    [Description("Account type Credit")]
    Credit = 1
} 
Run Code Online (Sandbox Code Playgroud)

我想展示我的intellisense的描述,这只是一个样本,我有许多必须解释的枚举.有一种方法可以做到这一点

c# enums

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

实体框架无效的列名称,EF将数字1添加到主键

我有这两个实体

public partial class Suscriptores
{
    public Suscriptores()
    {
       this.Publicacion = new HashSet<Publicacion>();
    }

    [Key]
    public int IdSuscriptor { get; set; }
    public string LogoSuscriptor { get; set; }
    public string Identificacion { get; set; }
    public string Nombre { get; set; }
    public string Direccion { get; set; }
    public string Telefono { get; set; }
    public string Email { get; set; }
    public string Fax { get; set; }
    public string Home { get; set; }

    public virtual …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-4 entity-framework-5

8
推荐指数
3
解决办法
8037
查看次数

asp.net mvc4更改jquery版本

我正在面对jquery的一些跨浏览器问题,经过一些研究我发现我的应用程序正在使用jquery 1.8.11或者至少我是这么认为的.

我的项目是一个带有c#的MVC4 asp.net应用程序.

实际上我正在尝试禁用 - 启用一些按钮,它在IE上工作正常,但不在chrome/firefox/safari中.

<ul class="ui-grid-d">
<li class="ui-block-a"><a id="MostrarDetallePedido" class="ui-btn ui-btn-up-a" disabled="disabled" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000041" data-role="button" data-theme="a" data-ajax="false"><span aria-hidden="true" class="ui-btn-inner"><span class="ui-btn-text">Detalle</span></span></a></li>
<li class="ui-block-b"><a id="ItemCondiciones" class="ui-state-disabled ui-btn ui-btn-up-b" disabled="disabled" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000041" data-role="button" data-theme="b" data-ajax="false"><span aria-hidden="true" class="ui-btn-inner"><span class="ui-btn-text">Condiciones</span></span></a></li>
<li class="ui-block-c"><a id="ItemEliminar" class="ui-state-disabled ui-btn ui-btn-up-c" disabled="disabled" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000041" data-role="button" data-theme="c" data-ajax="false"><span aria-hidden="true" class="ui-btn-inner"><span class="ui-btn-text">Eliminar</span></span></a></li>
<li class="ui-block-d"><a id="ItemAdiciones" class="ui-state-disabled ui-btn ui-btn-up-d" disabled="disabled" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000041" data-role="button" data-theme="d" data-ajax="false"><span aria-hidden="true" class="ui-btn-inner"><span class="ui-btn-text">Adiciones</span></span></a></li>
<li class="ui-block-e"><a id="ItemComponentes" class="ui-state-disabled ui-btn ui-btn-up-e" disabled="disabled" href="/Documentos/Docs/DocsDetalle?StrIdDocumento=01500___00000000000000041" data-role="button" data-theme="e" data-ajax="false"><span aria-hidden="true" class="ui-btn-inner"><span class="ui-btn-text">Componentes</span></span></a></li> 
</ul>?
Run Code Online (Sandbox Code Playgroud)

我试过了 …

c# asp.net-mvc jquery asp.net-mvc-3 asp.net-mvc-4

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

resx在项目之间共享

我有一个名为'mySolution'的解决方案,有两个项目:

  • 项目A
  • 项目B

ProjectA包含名为"mySolutionResources.resx"的资源文件.
ProjectB引用projectA,但无法访问mySolutionResources中的资源.

经过一些研究,我发现:"资源类都标记为内部".

我现在的问题是:

如果我只想维护一个'mySolutionResources.resx',我怎样才能从projectB访问它?如果不可能,还有另一种方法吗?

.net c#

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