Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: CollectionControl binding to WF Activity Designer

$
0
0
Hey,
I am building a set of Workflow Activities and a designer for the activity, one of which uses the XCeed CollectionControl to display a list of SQLParameters.

So, specifically, the WF Activity has a property which is a list of SQLParameters (List<SqlParameter>), which I would like to bind and be displayed in the CollectionControl. I'm still getting up to speed with WPF, so this might be somewhat obvious, but I've tried to bind it in different ways and can't.

Two problems:
  1. I don't understand which property to bind to on the Collection Control (I've tried both the Items on the control, as well as the ItemsSource, but neither seems to "connect")
  2. I have a IValueConverter, but while I can get the Convert() method to be called, I can never get the ConvertBack of the converter to be called (which would put the list from the control back into the Property of the containing activity).
Anyone have any pointers on how to bind a list of SQLParameters from a workflow activity into the CollectionControl both ways? Or a good example? Much appreciated because I'm still getting up to speed. :)

//Convert from the activity properties to the designer element
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        var modelItem = (ModelItem)value;
        if (modelItem != null)
        {
            var inArgument = modelItem.GetCurrentValue() as InArgument<List<SqlParameter>>;
            if (inArgument != null)
            {
                var expression = inArgument.Expression as Literal<List<SqlParameter>>;
                if (expression != null)
                {
                    var parameterList = expression.Value;
                    if (parameterList == null)
                        parameterList = new List<SqlParameter>();
                    return new ObservableCollection<SqlParameter>(parameterList);
                }
            }
        }
        return new ObservableCollection<SqlParameter>();
    }

    //Convert from the designer element to the activity property
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {       
        var itemContent = (ObservableCollection<SqlParameter>)value;
        var csArgument = new Literal<List<SqlParameter>>(itemContent.ToList());
        var inArgument = new InArgument<List<SqlParameter>>(csArgument);
        return inArgument;
    }
And from the XAML:
ModelItem.Parameters is the property on the container WF Activity. Thanks!

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>