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

RadComboBox and CallMethodAction

1 Answer 101 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Poubelle
Top achievements
Rank 1
Poubelle asked on 27 Feb 2012, 02:10 PM

Hi,

I’m developing a Gridview application in Silverlight, where i’ve got inside a CellEditTemplate with a RadComboBox. I need to call specific method in my ViewModel when i click in my RadComboBox. How can i redefine again my context to fin the method, because with my code (below), I’ve the error that say my RadGridView ItemSource do not contains my method.
Anyone can help me?
Thanks
Regards

<telerik:RadGridView x:Name="myPrdContent"
                        ItemsSource="{Binding ResultSearch2}"
                        AutoGenerateColumns="False"
                        ShowGroupPanel="False"
                        IsFilteringAllowed="False">
    <telerik:RadGridView.Columns>
 
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Age}"
                                    Width="*"
                                    MinWidth="200"
                                    >
            <telerik:GridViewDataColumn.Header>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <TextBlock Margin="2"
                                Text="Age"
                                Grid.Row="0" />
                </Grid>
            </telerik:GridViewDataColumn.Header>
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <telerik:RadComboBox x:Name="RadComboBox1" Margin="0 10 0 10" VerticalAlignment="Center"
                            CanAutocompleteSelectItems="False"
                            CanKeyboardNavigationSelectItems="False"
                            IsEditable="True"
                            IsReadOnly="False"
                            OpenDropDownOnFocus="False"
                            IsFilteringEnabled="False"
                            TextSearchMode="Contains"
                            IsDropDownOpen="False"
                            EmptyText="...::Empty::.."
                                                SelectedValue="{Binding SearchLibelle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                        Text="{Binding SearchLibelle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                        Width="300" DataContext="{Binding}" >
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="DropDownOpened">
                                <ei:CallMethodAction MethodName="Search" TargetObject="{Binding DataContext, ElementName=RadComboBox1}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </telerik:RadComboBox>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Poubelle
Top achievements
Rank 1
answered on 27 Feb 2012, 03:45 PM
Hi,

I’ve found a solution.
1) Add my ViewModel as ressouce in my window
<Window.Resources>
   <AppViewModel:MainWindowsViewModel x:Key="MyViewModel"/>
</Window.Resources>

2) Change the DataContext from the RadComboBox
DataContext="{Binding source={StaticResource MyViewModel}}"

Thanks all.
Tags
ComboBox
Asked by
Poubelle
Top achievements
Rank 1
Answers by
Poubelle
Top achievements
Rank 1
Share this question
or