This is a migrated thread and some comments may be shown as answers.

RadAutoCompleteBox and Blend Behaviours

1 Answer 68 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ingmar
Top achievements
Rank 1
Ingmar asked on 18 Nov 2014, 10:35 AM
Hi,

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

<Page
xmlns:Input="using:Telerik.UI.Xaml.Controls.Input"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core">
 
<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">
   <Interactivity:Interaction.Behaviors>
      <Core:EventTriggerBehavior EventName="SelectionChanged">
         <Core:InvokeCommandAction Command="{Binding ShowDetailsCommand}"/>
      </Core:EventTriggerBehavior>
   </Interactivity:Interaction.Behaviors>
</Input:RadAutoCompleteBox>

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,
Ingmar

1 Answer, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 19 Nov 2014, 09:20 AM
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.

Regards,
Ivaylo Gergov
Telerik
 

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.

 
Tags
AutoCompleteBox
Asked by
Ingmar
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Share this question
or