Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
XamComboEditor shows Value rather than Display Text
posted

Hi,

I'm having a strange issue with using XamComboEditor outside a DataGrid. In my custom user control, I have three XamComboEditors, each has a list of rating objects as its ItemsSource.

The problem is when I bind the control to its initial rating selections, the rating texts are displaying fine in two of the XamComboEditors, but in one of XamComboEditor is displaying the Value rather than the rating text. If I try replacing the XamComboEditors by WPF ComboBoxes then all is showing correctly.

What is more confusing is in the problemetic XamComboEditor, when I select from the dropdown menu, it displays the rating text correctly for some of the items, even after the XamComboEditor lose its focus. But for some items it displays the rating text on selection, and shows the Value instead after the XamComboEditor lose its focus.

Here is my xaml:

<infEditor:XamComboEditor Name="cboLongTerm" Grid.Column="0" Grid.Row="3" Width="58" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,2,2,2" Foreground="Black" Value="{Binding Path=LongTermRatingID, Mode=TwoWay}"IsEnabled="{Binding Path=IsEnabled}"/> 

<infEditor:XamComboEditor Name="cboOutlook" Grid.Column="1" Grid.Row="3" Width="58" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,2,2,2" Foreground="Black" Value="{Binding Path=OutlookRatingID, Mode=TwoWay}" IsEnabled="{Binding Path=IsEnabled}"/>  

<infEditor:XamComboEditor Name="cboShortTerm" Grid.Column="2" Grid.Row="3" Width="58" Height="20" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="2,2,2,2" Foreground="Black" Value="{Binding Path=ShortTermRatingID, Mode=TwoWay}" IsEnabled="{Binding Path=IsEnabled}"/>

 and I'm setting the ItemSource in code: 

public 

 

 

void PopulateRatings(List<RatingAgencyRating> ltratings,List<RatingAgencyRating> stratings,List<RatingOutlook> outlooks) {

cboLongTerm.ItemsSource = ltratings;

cboLongTerm.DisplayMemberPath =

"Rating";

cboLongTerm.ValuePath =

"AgencyRatingID";

cboShortTerm.ItemsSource = stratings;

cboShortTerm.DisplayMemberPath =

"Rating";

cboShortTerm.ValuePath =

"AgencyRatingID";

cboOutlook.ItemsSource = outlooks;

cboOutlook.DisplayMemberPath =

"Name";

cboOutlook.ValuePath =

"Id";

 

}

Has anyone had a similar problem before?

Thanks,

Tess

 

Parents
No Data
Reply
  • 430
    posted

    I am currently diagnosing a similar problem, although with the ComboBox in a grid on an AddNewRecord row. When the combobox is selected, it is correctly using the Editor template. However, when the combobox loses focus, it's occasionally displaying the class name (eg. Business.Customer), probably via to ToString() call. If you shift focus back to the cell, and select a value and shift focus away again, it usually displays the correct "selected item" display member text.

    I don't have a solution yet, but I am working with a similar problem.

Children