// Here is the Class
public class Items : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
static Items instance = null;
static readonly object padlock = new object();
Items()
{
}
public static Items Instance
{
get
{
lock (padlock)
{
if (instance == null)
{
instance = new Items();
}
return instance;
}
}
}
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));
}
}
public List<string> _ItemList = new List<string>();
public List<string> ItemList
{
get
{
return _ItemList;
}
set
{
_ItemList = value;
NotifyPropertyChanged("items");
}
}
}
//Here is the xaml code of the combobox
<ComboBox ItemsSource="{Binding ItemList, Mode=OneWay}"
// This is a function of the c# file from the UC where i want to bind the data
private void btnLoad_Click(object sender, RoutedEventArgs e)
{
if (items.ItemList.Count <= 0)
{
con.sendData("LoadItems");
}
ddItems.DataContext = Classes.Singleton.Items.Instance;
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.