title: Add and Biding comboboxEdit DevExpress
body: <p>Im trying to bind one combobox from my class that i linked in the context</p>
  
  <p>i have this in the control</p>
  
  <pre><code> &lt;dxe:ComboBoxEdit Width="100" Margin="5" Name="cboProduct" DisplayMember="Name"
                            SelectedItem="{Binding Path=DataContext.SelectedProduct, Mode=OneWay,  RelativeSource={RelativeSource AncestorType=Window}}"
                            &gt;
  
          &lt;/dxe:ComboBoxEdit&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/W97yu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W97yu.png" alt="It shows this"></a></p>
  
  <p>I filled the Combobox befor from code behind like this</p>
  
  <pre><code>var lsproducts = new List&lt;Product&gt;();
          var Products =_licenseService.GetProductList();
          Products.ForEach((x) =&gt; {
              lsproducts.Add(new Product(x.Name, x.ProductId));
          });
  </code></pre>
  
  <p>And im setting the SelectedProduct like this</p>
  
  <pre><code> [DataMember]
      public License SelectedLicense {
          get { return _SelectedLicense;}
          set {                      
              _SelectedLicense = value;                
              this.NotifyPropertyChanged("SelectedLicense");
          }
      }        
  
      public Product SelectedProduct
      {
          get
          {             
              return new Product(_SelectedLicense.Product.Name,_SelectedLicense.Product.ProductId);
          }             
      }
  
          this.cboProduct.ItemsSource = lsproducts.ToArray();
  </code></pre>
  
  <p>in both cases im using the object Product</p>
  
  <pre><code> using System;
   using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using pd.Common.Domain;
  
  namespace LicenceManagerWPF.Views
  {
  public class Product
  {
      public string Name { get; set; }
      public ProductEnum ProductID { get; set; }
  
      public Product(string ProductName,ProductEnum ID)
      {
          Name = ProductName;
          ProductID = ID;
      }
  
  }
  </code></pre>
  
  <p>i dont know why its not selecting the product when i open the window.</p>
  
  <p>i have another one 
  [![Shows like this][2]][2]</p>
  
  <p>I dont know why its display the x mark, but when i chouse another licence it updated the combo selection</p>
  
  <pre><code> &lt;dxe:ComboBoxEdit x:Name="cboActivationMode" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" Width="100" Style="{StaticResource TabMargin}"                                       
                                    SelectedItem="{Binding Path=DataContext.SelectedLicense.ActivationMode, RelativeSource={RelativeSource AncestorType=Window}}"
                                    /&gt;
  </code></pre>
  
  <p>The second one its only a couple of enums values that fill like this.</p>
  
  <pre><code> cboActivationMode.Items.Add(
              new DevExpress.Xpf.Editors.ComboBoxEditItem()
              { Content = Enum.GetName(typeof(ActivationMode), ActivationMode.Online), Tag = ActivationMode.Online });
  </code></pre>
  
  <p>How can i bind the values to a combobox?
  Regards</p>
  
  <pre><code>        cboActivationMode.Items.Add(            
              new DevExpress.Xpf.Editors.ComboBoxEditItem()
              {Content = Enum.GetName(typeof(ActivationMode), ActivationMode.Offline),Tag = ActivationMode.Offline});
  </code></pre>
  
  <p>I tryed to do this</p>
  
  <pre><code> public partial class LicenseDetail : UserControl
  {
      private readonly LicenseService _licenseService;
      public LicenseDetail()
      {
          InitializeComponent();
          _licenseService = new LicenseService();            
          FillCombos();
      }
  
      private void FillCombos()
      {
          FillProducts();
          FillActivationMode();
          //var str = Enum.GetName(typeof(ProductEnum), ProductEnum.CDSAddIn);
          //this.cboProduct.ItemsSource = new string[] { str };
      }
  
      private void FillProducts()
      {
  
          var Products = _licenseService.GetProductList();
          cboProduct.ItemsSource = Products;            
      }
  </code></pre>
  
  <p>The product list is a list of Iproduct (interface), i dont get i why they made it like this but each product is diferent they implement the same baseclass and the interface</p>
  
  <pre><code>[DataContract]
  public class ProductList : List&lt;IProduct&gt;
  {
      public bool Contains(ProductEnum productId)
      {
          return this.Any(x =&gt; x.ProductId == productId);
      }
  
      public IProduct GetProduct(ProductEnum productId)
      {
          return this.FirstOrDefault(x =&gt; x.ProductId == productId);
      }
  
      public void Remove(ProductEnum productId)
      {
          Remove(GetProduct(productId));
      }
  }
  </code></pre>
  
  <p>I changed the combo to bind like this
       SelectedItem="{Binding Path=DataContext.MyProduct, RelativeSource={RelativeSource AncestorType=Window}}"</p>
  
  <p>I create the property in the class like this
       public IProduct MyProduct
          {
              get { return _MyProduct; }
              set
              {
                  _MyProduct = value;
                  this.NotifyPropertyChanged("MyProduct");
              }
          }</p>
  
  <p>And assaing like this
       _CustomerLicense.MyProduct = SelectedLicense.Product;</p>
  
  <p>this is how the list of products is filled
        public IProduct GetProduct(ProductEnum productId)
          {
              IProduct product = null;</p>
  
  <pre><code>        var connection = GetConnection();
  
          try
          {
              var sql = string.Format(Resources.GetProduct, (int)productId);
              var cmd = new SqlCommand(sql, connection) { CommandType = CommandType.Text, Transaction = _transaction };
              using (var rdr = new NullableDataReader(cmd.ExecuteReader()))
                  while (rdr.Read())
                  {
                      var productName = rdr.GetString(0);
                      var featureId = rdr.GetInt32(1);
                      var featureDesc = rdr.GetString(2);
                      if (product == null)
                      {
                          switch (productId)
                          {
                              case ProductEnum.PDCalc:
                                  product = new PDCalcProduct(productId, productName);
                                  break;
                              case ProductEnum.PDMaint:
                                  product = new PDMaintProduct(productId, productName);
                                  break;
                              case ProductEnum.PBDynamics:
                                  product = new PBDynamicsProduct(productId, productName);
                                  break;
                              case ProductEnum.CDSAddIn:
                                  product = new CDSAddInProduct(productId, productName);
                                  break;
                          }
                      }
                      if (product != null)
                          product.Features.Add(new Feature((FeatureEnum)featureId, featureDesc));
                  }
          }
          finally
          {
              CloseConnection(connection);
          }
  
          return product;
      }
  </code></pre>
  
  <p>without any luck.
  Regards</p>