简体   繁体   中英

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. I have done this in VB.Net very successfully. 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. After selecting the above referenced the combobox displays "Address" which is correct.

LINQ Query:

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

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

ComboBox XAML Definition:

    <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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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