Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

how to synchronize bound comboxes

$
0
0
Hi all
I've created an application that consist of an observable collection of type site
and bound it to DataGrid that its rows consist of comboboxes,my questiin is
how to make the comboboxes of one row tobe synchronized with each other?,by mean
when i select an item from comobox it automaticly select the items in the others comboxes with the same index in the same row.
my site object as below
[Serializable]   
    public class CSite:INotifyPropertyChanged,ISerializable
        {
           public CSite()
                        {  }
             #region Fields Section
                string  _siteName;
                int     _siteID;
                int     _siteZone;
                string  _siteLocation;
                string  _siteConfiguration;
             #endregion
       [field:NonSerialized]
            public event PropertyChangedEventHandler PropertyChanged;
            void OnPropertyChanged(string probName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(probName));
                }
            }

 #region Properties Section
            public string SiteName
            {
                get { return _siteName; }
                set
                {
                    _siteName = value;
                    OnPropertyChanged("SiteName");
                }
            }

            public int SiteZone
            {
                get { return _siteZone; }
                set
                {
                    _siteZone = value;
                    OnPropertyChanged("SiteZone");
                }
            }


            public int SiteID
            {
                get { return _siteID; }
                set
                {
                    _siteID = value;
                    OnPropertyChanged("SiteID");
                }
            }

            public string SiteLocation
            {
                get { return _siteLocation; }
                set
                {
                    _siteLocation = value;
                    OnPropertyChanged("SiteLocation");
                }
            }

            public string SiteConfiguration
            {
                get { return _siteConfiguration; }
                set
                {
                    _siteConfiguration = value;
                    OnPropertyChanged("SiteConfiguration");
                }
            }
 #endregion
           
          #region Serialization Section
            //for reading stream
              CSite(SerializationInfo info, StreamingContext context)
            {
                SiteName = (string)info.GetString("siteName");
                SiteZone = (int)info.GetInt32("siteZone");
                SiteID = (int)info.GetInt32("siteID");
                SiteLocation = (string)info.GetString("siteLocation");
                SiteConfiguration = (string)info.GetString("siteConfiguration");
            }
            //for writing stream
            public void GetObjectData(SerializationInfo info, StreamingContext context)
            {
                info.AddValue("siteName", SiteName);
                info.AddValue("siteZone", SiteZone);
                info.AddValue("siteID", SiteID);
                info.AddValue("siteLocation", SiteLocation);
                info.AddValue("siteConfiguration", SiteConfiguration);
            }
 #endregion
        }
    }


my data grid sample
<DataGrid.Columns><DataGridTemplateColumn Header="ID"><DataGridTemplateColumn.CellTemplate ><DataTemplate><TextBlock Text="{Binding IssuedSite.SiteID}"></TextBlock></DataTemplate></DataGridTemplateColumn.CellTemplate><DataGridTemplateColumn.CellEditingTemplate><DataTemplate><ComboBox  Name="idcombx" 
                                       ItemsSource ="{Binding Source={StaticResource tetsites},Path=SitesColl}"
                                       DisplayMemberPath="SiteID"
                                       SelectedValuePath="SiteID"
                                       SelectedValue="{Binding IssuedSite.SiteID}" GotFocus="idcombx_GotFocus"></ComboBox></DataTemplate></DataGridTemplateColumn.CellEditingTemplate></DataGridTemplateColumn>

Viewing all articles
Browse latest Browse all 2703

Trending Articles