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 issue and it seems that it occurs because the ‘Columns’ is read-only property. You can try to use the methods of the ‘Columns’ property in order to manipulate it.
If you need any further assistance, feel free to ask.
Can you provide an exmaple because when I bind to using the code below I get an error:
'Collection property 'MultiColumnDropdownList'.'Columns' is null.' Line number '193' and line position '34'.
Code:
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(new PropertyChangedCallback(OnColumnsChanged)));
protected static void OnColumnsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e){
MultiColumnDropdownList myMultiCombo = sender as MultiColumnDropdownList;
myMultiCombo.FieldMultiCombo.Columns.Add((ComboColumn)e.NewValue);
Hello Yanko,
thank you very much.
Your solution worked for me!
Best regards,
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.
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
This helped, thanks.
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. :
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.