Posts

Showing posts with the label combobox

WPF: How to data bind a ComboBox to ListView selection and set the ComboBox value range?

WPF: How to data bind a ComboBox to ListView selection and set the ComboBox value range? I'm new in WPF land and have the following question regarding data binding. My test app contains a ListView with cars (Colums: Type, Speed and Color). Below the list view there are some controls to control the selected car's values. Among others there's a ComboBox to choose the selected car's color. My test app looks like this In XAML the ListView is initialized like this: <ListView Grid.Row="1" Name="listView" ItemsSource="{Binding Model.Cars}" SelectedValue="{Binding Model.SelectedCar}"> <ListView.View> <GridView> <GridView.Columns> <GridViewColumn Header="Type" Width="Auto" DisplayMemberBinding="{Binding Name}" /> <GridViewColumn Header="Speed" Width="Auto" DisplayMemberBinding="{Binding Speed}" /> <Gri...

WPF Combobox selectedindex binding

WPF Combobox selectedindex binding I have difficulties binding the selectedindex of a combobox to an object. This is my code: (Part of) CustomerClass public class Customer : INotifyPropertyChanged { public int CountryCode { get { return _CountryCode; } set { _CountryCode = value; NotifyPropertyChanged(); } } } 2a. (Part of) CustomListItem <ComboBox x:Name="cboCountryCode" Grid.Column="5" ItemsSource="{Binding}" DisplayMemberPath="LongName" SelectedIndex="{Binding CountryCode, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> 2b. (Part of) CustomListItem public partial class CustomerListItem : UserControl { public CustomerListItem() { InitializeComponent(); ObservableCollection<CountryCode> Liste = CountryCodes.Instance.List; cboCountryCode.DataContext = Liste; } (Part of) MainPage <ItemsControl Name="itcCustomers...