Hi,
I have been trying to put XamComboEditor Control inside XamRibbon. Is this something can be achieved or not? I placed Combobox inside ribbon successfully but not the XamComboEditor. I am getting some error saying Property 'Template' was not found in type 'XamComboEditor Tool'
I could not attach whole silverlight project so I included the necessary files to look into. PLease help!!
Looking at your code, there are two reasons for this not to work:
1. Ribbon's Tools are not FrameworkElements, so you cannot bind them to a DataContext (they simply doesn't have such property so they don't inherit Ribbon's DataContext). So setting a DataContext on the ribbon will not cause ribbon's tools to bind to that DataContext. In this case, you should bind the ItemsSource of the ComboEditorTool directly.
2. The ItemsSource of the XamComboEditor is set only once, in "OnApplyTemplate" method of the ComboEditorTool. Setting new ItemsSource on the Tool later (e.g., on the Loaded event) will not set this new ItemsSource on the XamComboEditor. You should modify the logic of the ComboEditorTool so when it's ItemsSource property changes it updates the ItemsSource property of the XamComboEditor inside ComboEditorToolControl's template.
I created a quick mockup sample that demonstrates that. It's not perfect, but you'll get the idea.
Hope this helps,
Thanks for the reply. I got the combo editor showing up in my xaml page. But the problem now I have is binding data to comboeditor.
I am calling LoadCombo in Usercontrol_loaded method like this
Ribbon.Loaded +=
new RoutedEventHandler(LoadCombo);
public void LoadCombo(object sender, RoutedEventArgs e){
marketsQuery.BeginExecute(GridDataLoadCompleted, marketsQuery);
}
{
_marketAlerts =
new ObservableCollection<MarketDataClass>();
marketAlerts.EndExecute(asyncResult).ToList())
_marketAlerts.Add(marketAlertEntity);
cbt.DisplayMemberPath =
"MarketName";
Ribbon.DataContext = _marketAlerts;
cbt.Ribbon.UpdateLayout();
The cbt control at runtime has Itemsource values. But not showing up on UI. Please help soon. It has been three days I am working on this xameditorcontrol inside ribbon.
I looked at the files you attached. From what I've seen, you need to change the target type of both the Style and the ControlTemplate in your App.xaml to "local:XamComboEditorToolControl" instead of "local:XamComboEditorTool".
Hope that helps,