Aug 7, 2012 at 9:53 AM
Edited Aug 7, 2012 at 10: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?
|