Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Bind ComboBox SelectedItem to a property of View Model

$
0
0

Hi I am trying to bind my ComboBox selected Item to a property in my view model where a setter will take this value and perform some other logic. Now my ComboBox is working correctly pulling items off an observablecollection Systems however I have been unable to bind the selectedItem which is a serial to a property. The selected item in my current xaml selected value is not binding to the string value of the ComboBox. Everything else is ok the DataContext is assigned to the view in the code behind. Any ideas this is my viewModel and below my xaml:

public class CablingRequests : ObservableCollection<CablingRequest>
{
    public ObservableCollection<CablingRequest> PendingRequests { get; set; }
    public ObservableCollection<CablingRequest> ProcessedRequests { get; set; }
    public ObservableCollection<CablingRequest> Systems { get; set; }
    public ObservableCollection<CablingRequest> SelectedSystemConfiguration { get; set; }

    private string _serial;
    public string Serial
    {
        get { return _serial; }
        set
        {
            if (_serial == value)
                return;
            _serial = value;
            GetSelectedSystemConfiguration(_serial);
        }
    }


<ComboBox x:Name="ComboBoxSerial" ItemsSource="{Binding Path=Systems}" DisplayMemberPath="SerialNumber" SelectedValue="{Binding Path=Serial, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True" MinWidth="150" />


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>