RadAutoCompleteBox and Blend Behaviours

2 posts, 0 answers
  1. Ingmar
    Ingmar avatar
    8 posts
    Member since:
    Jun 2009

    Posted 18 Nov 2014 Link to this post


    I’m trying to use the RadAutoCompleteBox combined with a MVVMLight ViewModel. Due to MVVMs
    design principles I have to use commands instead of events which got me to
    Expression Blends Behaviours.

    My implementation

    <Input:RadAutoCompleteBox x:Name="AutoCompleteBox" ItemsSource="{Binding Profiles}" FilterMemberPath="Name" FilterMode="Contains"  DisplayMemberPath="Name" HorizontalAlignment="Left" Margin="10,29,0,0" Grid.Row="1" VerticalAlignment="Top">
          <Core:EventTriggerBehavior EventName="SelectionChanged">
             <Core:InvokeCommandAction Command="{Binding ShowDetailsCommand}"/>

    results in the following exception being thrown:

    WinRT information: Cannot add instance of type 'Microsoft.Xaml.Interactions.Core.EventTriggerBehavior' to a collection of type 'Microsoft.Xaml.Interactivity.BehaviorCollection'

    Is it possible to use Teleriks RadAutoCompleteBox for Windows Universal in combination with Expression Blends Behaviours? if so what am I doing wrong?

    Kind regards,
  2. Ivaylo Gergov
    Ivaylo Gergov avatar
    661 posts

    Posted 19 Nov 2014 Link to this post

    Hi Ingmar,

    I investigated this problem and I found that this is a bug in the Behaviors SDK. It seems that it does not recognize an event which is registered in a custom class and it is of type that is not declared in the System.ComponentModel namespace. For example : SelectionChangedEventHandler. A workaround could be to copy/paste the declaration of the delegate in the custom class. 
    In this case, the only workaround would be to create a class that derives from the RadAutoCompleteBox and register a new event similar to the SelectionChanged and trigger it when the SelectionChanged event is triggered. 
    For your convenience, I have attached a sample project which shows how to achieve the workaround. Also, there is an example of a custom class that derives from Button to demonstrate where the problem comes from. You can see that if you remove the copy/pasted delegate the Behaviors SDK will not recognize the event:
    //    Comment the copy/pasted delegate to break the app.
    public delegate void SelectionChangedEventHandler(object sender, SelectionChangedEventArgs e);

    Let me know if this helps.

    Ivaylo Gergov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top