Carlos Gravato

In BindUITypeEditor is there a way to restrict the type of properties that appear to the user For example: only show properties of type int or decimal.

Or do I need to define an editor myself And if so, how do I restrict the types showed

Thanks


Re: Windows Workflow Foundation Restrict the type of the properties in BindUITypeEditor

Konstantin Vyaznikov

Your custom activity should implement ITypeFilterProvider interface, kind of:

Code Snippet

#region ITypeFilterProvider Members

/// <summary>
/// Filters types for the Class Browser Dialog
/// </summary>
/// <param name="type"></param>
/// <param name="throwOnError"></param>
/// <returns></returns>
public bool CanFilterType(Type type, bool throwOnError)
{
if (type.IsClass)
{
if (type.BaseType == typeof(SoapHttpClientProtocol))
{
return true;
}
}

return false;
}

/// <summary>
/// Description for the Class Browser Dialog
/// </summary>
[Browsable(false)]
public string FilterDescription
{
get { return "Choose a proxy class"; }
}

#endregion

In this case only classes which are derived from SoapHttpClientProtocol are shown in dialog.

Thanks,

Konstantin.





Re: Windows Workflow Foundation Restrict the type of the properties in BindUITypeEditor

Tom Lake - MSFT

Don't forget to add the following attribute to the top of the property:

[TypeFilterProviderAttribute(typeof(ProtocolTypeFilterProvider))]






Re: Windows Workflow Foundation Restrict the type of the properties in BindUITypeEditor

Carlos Gravato

This is the code I wrote:

public class NumericTypeFilter : ITypeFilterProvider
{
public NumericTypeFilter()
{
}

public bool CanFilterType(Type type, bool throwOnError)
{
if (type != null)
{
if (type.BaseType == typeof(int) || type.BaseType == typeof(decimal))
{
return true;
}
}

return false;
}

[Browsable(false)]
public string FilterDescription
{
get { return Properties.Resources.ChooseNumericProperty; }
}
}

And then I added this attribute to the properties I wanted:
[TypeFilterProvider(typeof(NumericTypeFilter))]

But still... it's not filtering anything.

Help, please.





Re: Windows Workflow Foundation Restrict the type of the properties in BindUITypeEditor

Matt Milner - Pluralsight

Carlos,

If you are trying to customize the ActivityBind dialog, then the suggestions here won't help you. The suggestions in this thread provide very good information about how to filter the TypeSelection dialog like you see when you choose an interface for the CallExternalMethod activity.

If you want to customize the Activity Bind Dialog, you'll have to do a lot more work. Check this thread for information on creating a custom bind dialog and hooking into an editor.

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=889310&SiteID=1

Thanks,

Matt