Binding issue with Telerik GridView

Topics: Conventions
Aug 7, 2012 at 10:53 AM
Edited Aug 7, 2012 at 11:01 AM

Hi,

I'm new to Caliburn.Micro and I have an issue on binding.

I have a silverlight application and I use Telerik GridView. I want to intercept the "addingNewDataItem" event on the grid using the Caliburn.Micro conventions. I firstly used "Interaction.Triggers"

<telerik:RadGridView x:Name="EcrituresGridView"
                                             Margin="5"                                             
                                             Grid.Row="1"
                                             ItemsSource="{Binding Source={StaticResource SortedEcritures}}"
                                             SelectedItem="{Binding SelectedEcritureComptableItem, Mode=TwoWay}"
                                             IsReadOnly="False" ShowColumnFooters="False" 
                                             ShowInsertRow="True"
                                             ShowGroupPanel="False"
                                             CanUserInsertRows="True"                                            
                                             RowIndicatorVisibility="Visible"
                                             AutoGenerateColumns="False"
                                             ShowGroupFooters="True">

                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="AddingNewDataItem">
                                    <cal:ActionMessage MethodName="AddingNewEcritureItem">
                                        <cal:Parameter Value="$eventArgs" />
                                    </cal:ActionMessage>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>

                            <telerik:RadGridView.Columns>

</telerik:RadGridView.Columns>

</telerik:RadGridView>

then I tried "cal:Message.Attach"

<telerik:RadGridView x:Name="EcrituresGridView"
                                             Margin="5"                                             
                                             Grid.Row="1"
                                             ItemsSource="{Binding Source={StaticResource SortedEcritures}}"
                                             SelectedItem="{Binding SelectedEcritureComptableItem, Mode=TwoWay}"
                                             IsReadOnly="False" ShowColumnFooters="False" 
                                             ShowInsertRow="True"
                                             ShowGroupPanel="False"
                                             CanUserInsertRows="True"                                            
                                             RowIndicatorVisibility="Visible"
                                             AutoGenerateColumns="False"
                                             ShowGroupFooters="True"
					     cal:Action.TargetWithoutContext="{Binding}"
                                             cal:Message.Attach="[Event AddingNewDataItem] = [Action AddingNewEcritureItem($eventArgs)]">

                            <telerik:RadGridView.Columns> 
 </telerik:RadGridView.Columns>
</telerik:RadGridView>

but the event has never been fired.

(Remark: I have not to use code behind on the view).

To make that Working, I deleted the Caliburn.Micro binding and I used an explicit subscription on the ViewModel.

 

 protected override void OnViewLoaded(object view)
        {
            base.OnViewLoaded(view);

            _gridView = ((ListeEcrituresComptablesView) view).EcrituresGridView;
            _gridView.AddingNewDataItem += AddingNewEcritureItem;
        }

 

But this is the worst way to do that because there is a high coupling between View and ViewModel.

My question is What’s the solution to make caliburn take care of this binding?

Aug 21, 2012 at 9:58 AM

Hi again,

Is there any solution or workaround to make Caliburn taking care of AddingNewDataItem binding between gridView and it's ViewModel?

Aug 23, 2012 at 11:04 AM

I don't use Silverlight or Telerik controls, but I just wanted to mention this

 http://blog.caraulean.com/2011/06/05/integration-of-caliburn-micro-and-teleriks-silverlight-controls/

in case it was of use.
I'm sure it will help
Cheers