views:

45

answers:

1

Following on from my other post about primary keys I am wondering if there is a performance impact in using a string value as the key in WPF comboboxes. For example

<ComboBox x:Name="TestCB" ItemsSource="{Binding Path=Products}" DisplayMemberPath="ProductName" 
                  SelectedValuePath="ShortCode" SelectedValue="{Binding Path=SelectedProduct.ShortCode, Mode=TwoWay}"/>

As ShortCode and SelectedProduct.ShortCode are of type string, would it be slower to find the SelectedItem when the source changes as opposed to having an int such as ProductID. If so, what is the logic behind this i.e. no full text indexing.

+1  A: 

Unless you have millions of items in your combobox (which would be awful for the user experience), I don't think it will have a significant impact on performance... Comparisons on short strings are fast, even though not as fast as integer comparisons...

Thomas Levesque