CSLA4 TriggerEvent for DataGrid

CSLA4 TriggerEvent for DataGrid

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


HK.Lee posted on Thursday, May 13, 2010

Hi all,

I am trying to move my simple sample app which is written v3.81 into  4.0 to study new fetures of  4.0.      For the new TriggerEvent, it works fine in other controls such as button's click but doesn't  in datagrid's SelectionChanged.

This form is very simple one which adds and edits user, and consists of edit form(BusinessBase) in the upper and  user list(ReadOnlyList) in the down side.

My code sippet is as follwows;

        <!-- MVVM resource -->

 <UserControl.Resources>
        <CollectionViewSource x:Key="adminUserViewModelViewSource" d:DesignSource="{d:DesignInstance this:AdminUserViewModel, CreateList=True}" />
        <!--<CollectionViewSource x:Key="adminUserListViewSource" Source="{Binding Path=AdminList, Source={StaticResource adminUserViewModelViewSource}}" />-->
    </UserControl.Resources>

.  other codes

.

   <telerikGrid:RadGridView x:Name="dataGrid" ItemsSource="{Binding AdminList}"         Style="{StaticResource ReadonlyGridStyle}"
                         Foreground="Black"  BorderThickness="0" FontSize="13.333" Margin="1,1,1,1"
                           Tag="{Binding RelativeSource={RelativeSource Self},Path=SelectedItem}">
                <telerikGrid:RadGridView.Columns>
                    <telerikGrid:GridViewDataColumn Width="100" Header="user" DataMemberBinding="{Binding UserName}"/>
                    <telerikGrid:GridViewDataColumn Width="100" Header="title"     

. more columns

.

            </telerikGrid:RadGridView.Columns>
            </telerikGrid:RadGridView>
        </Border>
        <my:TriggerAction x:Name="rowChange" TargetControl="dataGrid" Height="0" Width="0"
                          TriggerEvent="SelectionChanged" MethodName="ShowUser" />

For this sample, I'm referencing Rocky's VS 2010 Launch project - Collective. When view initiates, other button's(add/save tec) triggeraction attaches fine but broken on reaching datagrid's one.        The error message is 'dataGrid' did not create System.Windows.FrameworkElement.  If I remov e TriggerAction, view runs fine,of course I can't use SelectionChanged event. Same error happened when I change Windows.Contorls.Dat.DataGrid instead of telerik's one.                                                       I used same declaration with button's click event and don't know what's going wrong.

Pls advise me. Thank you in advance.

HK.Lee

 

 

RockfordLhotka replied on Thursday, May 13, 2010

TargetControl requires a binding expression like "{Binding ElementName=dataGrid}"

HK.Lee replied on Thursday, May 13, 2010

Hi Rocky,

 

Thank you for your kind reply.  How stupid I am.<sigh>

HK.Lee

 

Copyright (c) Marimer LLC