Hi,
I am using a xamcomboeditor inside a xamribbon.Followed the following sample
http://forums.infragistics.com/forums/p/50014/263304.aspx
how do we get selecteditems of xamcomboeditortool?
thanks.
Hello,
I have been looking into your question and I can suggest you define properties for the fields in the ‘XamComboEditorToolControl’ and ‘XamComboEditorTool’ classes. Using them you can access the XamComboEditor in the XamComboEditorTool. I am sending you a modified version of the sample application(RibbonSample Modified.zip) from the provided forum thread link.
If you need any further assistance, feel free to ask.
hi,
thank you for your reply.
i have created the properties for selecteditem and event handler for selectionchanged as shown. But the issue is comboeditortool.selecteditem is always null. Can you please let me know the issue in the following code?
public class XamComboEditorTool : RibbonTool { private XamComboEditorToolControl _control; public XamComboEditorToolControl Control { get { return _control; } set { _control = value; } } private void UpdateBindings() { if (this._control != null) { this._control.OnApplyTemplate(); } } protected override RibbonToolBaseControl ResolveToolControl() { XamComboEditorToolControl control = new XamComboEditorToolControl(this); if (this._control == null) { this._control = control; } return control; } public IEnumerable ItemsSource { get { return (IEnumerable)GetValue(ItemsSourceProperty); } set { SetValue(ItemsSourceProperty, value); this.UpdateBindings(); } } public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(XamComboEditorTool), null); public String DisplayMemberPath { get; set; } public object SelectedItem { get { return (object)GetValue(SelectedItemProperty); } set { SetValue(SelectedItemProperty, value); this.UpdateBindings(); } } public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register("SelectedItem", typeof(object), typeof(XamComboEditorTool), new PropertyMetadata(null)); public event EventHandler SelectionChanged; public void SelectionChangedEventHandler(object sender, EventArgs e) { if (SelectionChanged != null) SelectionChanged(sender, e); } } public class XamComboEditorToolControl : RibbonToolBaseControl, IRibbonControl { private XamComboEditor _combo; public XamComboEditor Combo { get { return _combo; } set { _combo = value; } } public XamComboEditorToolControl() { this.DefaultStyleKey = typeof(XamComboEditorToolControl); } public XamComboEditorToolControl(RibbonToolBase tool) : base(tool) { this.DefaultStyleKey = typeof(XamComboEditorToolControl); } public override void OnApplyTemplate() { base.OnApplyTemplate(); this._combo = GetTemplateChild("XamComboEditor") as XamComboEditor; if (this._combo != null) { this._combo.ItemsSource = ((XamComboEditorTool)this.Tool).ItemsSource; this._combo.DisplayMemberPath = ((XamComboEditorTool)this.Tool).DisplayMemberPath; this._combo.SelectionChanged += new EventHandler(((XamComboEditorTool)this.Tool).SelectionChangedEventHandler); this._combo.SelectedItem = ((XamComboEditorTool)this.Tool).SelectedItem; } } }