简体   繁体   English

C#,Linq,实体框架组合框

[英]C#, Linq, Entity Framework Combobox

I am currently having an issue I can't seem to resolve. 我目前遇到一个似乎无法解决的问题。 I've created a method, where I pass in a combobox object, build a Linq Query and bind the ItemsSource to the result of the query. 我创建了一个方法,在该方法中,我传入了一个组合框对象,构建了一个Linq查询,并将ItemsSource绑定到查询的结果。 I have done this in VB.Net very successfully. 我已经在VB.Net中非常成功地做到了这一点。 In C# though When I debug the application and pulldown the combobox I'm seeing the following: System.Data.Entity.DynamicProxies.ReferenceGroup_FEA77E50BE7F55D3AD4A32EC3E42F6 If I select the entry, then the correct DisplayPath and the Selected Value Path are working correctly. 虽然在C#中,当我调试应用程序并下拉组合框时,看到以下内容: System.Data.Entity.DynamicProxies.ReferenceGroup_FEA77E50BE7F55D3AD4A32EC3E42F6如果我选择该条目,则正确的DisplayPath和“选定值路径”将正常工作。 After selecting the above referenced the combobox displays "Address" which is correct. 选择上述参考后,组合框显示正确的“地址”。

LINQ Query: LINQ查询:

    var source = (from g in adminEntities.ReferenceGroups
                  orderby g.ReferenceGroupName
                  select g);

   objSource.ItemsSource = source.ToList();
   return objSource;

ComboBox XAML Definition: ComboBox XAML定义:

    <ComboBox Name="cboGroups" Grid.Column="1" Grid.Row="0" 
      HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5"  
      SelectionChanged="cboGroups_SelectionChanged"
      DisplayMemberPath="ReferenceGroupName"
      SelectedValuePath="ReferenceGroupID"/>

This behavior is defferent between C# and VB.Net. 此行为在C#和VB.Net之间是不同的。 Any help would greatly be appreciated. 任何帮助将不胜感激。

I have figured out my issue. 我知道了我的问题。 The displaying of the combobox entries is related to my WPF Theme and the Control Styling. 组合框条目的显示与我的WPF主题和控件样式相关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM