I am needing to style a ComboBoxItem for a ComboBox that is being created in code behind. Here's my code so far
ComboBox cbo1 = new ComboBox();
cbo1.IsTextSearchEnabled = true;
cbo1.IsEditable = true;
grid1.Children.Add(cbo1);
cbo1.Dispatcher.BeginInvoke(new StyleComboBoxItemDelegate(ref StyleComboBoxItem(cbo1), System.Windows.Threading.DispatcherPriority.Background);
public delegate void StyleComboBoxItemDelegate(ComboBox cbo_tostyle);
public void StyleComboBoxItem(ComboBox cbo_tostyle)
{
//code to style the comboboxitem;
}
I am getting the following errors
1. A ref or out argument must be an assignable variable
2. Method name expected
Please can someone help me in pointing as to what I am doing wrong?
Many Thanks
Try using either of these:
cbo1.Dispatcher.BeginInvoke(
(Action)(() => StyleComboBoxItem(cbo1)),
System.Windows.Threading.DispatcherPriority.Background);
cbo1.Dispatcher.BeginInvoke(
(Action)(() =>
{
//code to style the comboboxitem;
}),
System.Windows.Threading.DispatcherPriority.Background);