I'm trying to create a user control which will have a label and XamMultiColumnComboEditor. However the issue I'm running into is exposing XamMultiColumnComboEditor.Columns so programmers can specify which columns to show and hide. Is there a way to do that? It didn't like using this:
public ComboColumnCollection Columns { get { return (ComboColumnCollection)GetValue(ColumnsProperty); } set { SetValue(ColumnsProperty, value); } }
public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register("Columns", typeof(ComboColumnCollection), typeof(MultiColumnDropdownList), new FrameworkPropertyMetadata(null));
Hello,
I am checking if this is still an issue for you.
If you require any further assistance please do not hesitate to ask.
In my case since I'm creating a user control I have to expose those properties by binding to them. I'm binding properties to dependacy properties like below:
CustomItemsFilter="{Binding Path=CustomItemsFilter, ElementName=UserControl}"DisplayMemberPath="{Binding Path=DisplayMemberPath, ElementName=UserControl}"
...
public ItemsFilter CustomItemsFilter { get { return (ItemsFilter)GetValue(CustomItemsFilterProperty); } set { SetValue(CustomItemsFilterProperty, value); } }
public static readonly DependencyProperty CustomItemsFilterProperty = DependencyProperty.Register("CustomItemsFilter", typeof(ItemsFilter), typeof(AwrdsMultiColumnDropdownList), new FrameworkPropertyMetadata(null));
public string DisplayMemberPath { get { return (string)GetValue(DisplayMemberPathProperty); } set { SetValue(DisplayMemberPathProperty, value); } }
public static readonly DependencyProperty DisplayMemberPathProperty = DependencyProperty.Register("DisplayMemberPath", typeof(string), typeof(AwrdsMultiColumnDropdownList), new FrameworkPropertyMetadata(null));
However I can't figure out how to do this with the columns attribute.
I have been looking into your post and I assume that the setter is not working in your implementation because the ‘Columns’ property by default is read-only. You can try add manually items into your column property like e.g. :
public ComboColumnCollection Columns
{
get { return (ComboColumnCollection)GetValue(ColumnsProperty); }
set
SetValue(ColumnsProperty, value);
((this.Content as Grid).Children[0] as XamMultiColumnComboEditor).Columns.Clear();
foreach (var item in value)
((this.Content as Grid).Children[0] as XamMultiColumnComboEditor).Columns.Add(item);
}
If this does not meet your scenario, please attach a sample application in order to see your current implementation and provide you with more accurate assistance.
This helped, thanks.
i'm trying to do the exact same thing (building a User Control with XamMultiColumnComboEditor and bind the Columns property to the templated parent), but i wasn't able to accomplish that.
I attached an example which should explain all.
Thanks,Jochen
Hello Jochen,
I have been looking into your requirement and I am attaching a sample application(MultiComboAsEditor.zip) that show how you can achieve the desired functionality.
Let me know, if you need any further assistance on this matter.
Hello Yanko,
thank you very much.
Your solution worked for me!
Best regards,
Jochen