csla:TriggerAction for SelectionChanged in DataGrid ; Xaml ; csla.net 4 ; ViewModel

csla:TriggerAction for SelectionChanged in DataGrid ; Xaml ; csla.net 4 ; ViewModel

Old forum URL: forums.lhotka.net/forums/t/9775.aspx


JJLoubser posted on Wednesday, November 17, 2010

why cannot i dot this?:

 

 <telerikNavigation:RadTreeView x:Name="radTreeView"
                                    BorderThickness="1"
                                    BorderBrush="Black"
            HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ItemsSource="{Binding OrgStructList}"
                                    ItemTemplate="{StaticResource RootItem}"
                                    Width="300"
                                    />

                        <!--SelectionChanged="radTreeView_SelectionChanged"-->


                        <csla:TriggerAction Height="0" Name="SetGridTrigger" Width="0"
                                            TargetControl="{Binding SelectionChanged, ElementName=radTreeView}" MethodName="SetGrid_SelectionChanged" />

 

The Trigger Action do not work for this in my ViewModel, normal buttton events always work:

 

public void SetGrid_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
   {

   }

Mission is not to use Code Behind.

RockfordLhotka replied on Wednesday, November 17, 2010

The TargetControl binding is wrong. That needs to point directly to the control, and you need to use the TriggerEvent property to indicate the name of the event for which you want to listen.

TargetControl="{Binding ElementName=radTreeView}" TriggerEvent="SelectionChanged"

 

JJLoubser replied on Thursday, November 18, 2010

xaml

 

<StackPanel Orientation="Vertical" Margin="5"
                                DataContext="{Binding Source={StaticResource WorkRuleViewModelViewSource}}"
                        >

                        <telerikNavigation:RadTreeView x:Name="radTreeView_"
                                    BorderThickness="1"
                                    BorderBrush="Black"
            HorizontalAlignment="Stretch"
                                    VerticalAlignment="Stretch"
                                    ItemsSource="{Binding OrgStructList}"
                                    ItemTemplate="{StaticResource RootItem}"
                                    Width="300"
                                    >

                          
                           
                        </telerikNavigation:RadTreeView>
                            <!--SelectionChanged="radTreeView_SelectionChanged"-->

 

                        <csla:TriggerAction Height="0" Name="SetTreeTrigger" Width="0"
                                            TargetControl="{Binding ElementName=radTreeView_}" TriggerEvent="SelectionChanged" MethodName="SetTree_SelectionChanged"
                                                />
                          

</stackpanel>

error: child is already a child of another element.

eish what?

 

 

dcleven replied on Thursday, November 18, 2010

</stackpanel>

should be

</StackPanel>

JJLoubser replied on Friday, November 19, 2010

Cool I typed in my questions only a spelling error - my code is </StackPanel> still same error.

 

dcleven replied on Friday, November 19, 2010

Hmmm... I pasted the code and corrected the references (I am using Telerik as well) and it did not complain. You may have a problem in a different part of the code that you didn't show?

Another option: Bind the SelectedItem from the RadTreeView to a Property in your view model then handle the property changed event to process the selection changing.

Copyright (c) Marimer LLC