开发者

Help with the Action/Event behind a ComboBox

I've been looking at this post to help populate my ComboBox: Binding WPF ComboBox to a Custom List.

My ComboBox is populated with an object, where a "name" property populates the list. This is what it looks like so far:

<ComboBox x:Name="SampleComboBox" ItemsSource="{Binding Path=SelectedSamples}" DisplayMemberPath="SampleName" SelectedValue="{Binding Path=SampleName}"
                          SelectedItem="{Binding Path=SelectedSample}"/>
开发者_JAVA技巧

Sorry for the horrible naming convention, but I was just trying to get a prototype working. Basically the list gets populated off a table when items are selected in a table. So the ItemsSource is that collection of Sample objects.

From my understanding (could be wrong, feel free to correct me), the DisplayMemberPath is what is to be displayed in the box. So in this case, the Sample object property is SampleName.

The SelectedValue and SelectedItem I'm not sure exactly what those are :( . What I do know, is I want to be able to have an action that when one of the Samples is selected, I change the SelectedSample (single instead of plural) property in order to update other things in my program.

Hopefully that makes sense. Any thoughts? Thanks.


You could attach a handler to the SelectionChanged event on the ComboBox. MSDN doc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜