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

Radcombox within a datatemplate not binding

1 Answer 62 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
peter
Top achievements
Rank 1
peter asked on 29 Mar 2012, 10:15 AM

Hi I have an datatemplate which i have created for my raddataform, the problem i am getting is that within the datatemplate i have a radcombobox, and when loaded i want the selected value to be bound to the value form a radgridview, which is outside of the datatemplate. However this doesnt work. Here is what the datatemplate looks like;

             <DataTemplate x:Key="eventHeaderEditTemplate" 
                    <Grid
                        <Grid.RowDefinitions
                            <RowDefinition Height="Auto"/> 
                        </Grid.RowDefinitions
                        <Grid Margin="8,8,0,0" d:LayoutOverrides="Height"
                            <Grid.ColumnDefinitions
                                <ColumnDefinition Width="150" /> 
                                <ColumnDefinition Width="*" /> 
                            </Grid.ColumnDefinitions
                            <Grid.RowDefinitions
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                                <RowDefinition /> 
                            </Grid.RowDefinitions
                                           <TextBox x:Name="txtEventStateID" Text="{Binding SelectedItem.EventHeader.EventStateID, ElementName=staticDataRadGrid}" TextWrapping="Wrap" FontFamily="Segoe UI" FontSize="14" Foreground="{StaticResource StrongBrush}" Grid.Column="1" Grid.Row="6"  Margin="0,0,0,2" /> 
    
                            <Telerik:RadComboBox ItemsSource="{Binding EventStateDTOs,Source={StaticResource EventStateDTOViewModel},Mode=TwoWay}"    x:Name="comboBoxEventState"
Grid.Column="1" SelectedValue="{Binding SelectedItem.EventHeader.EventStateID, ElementName=staticDataRadGrid}"   Style="{StaticResource RadComboBoxStyle}" FontFamily="Segoe UI Light"  FontSize="24" Margin="0,0,0,2" Grid.Row="7" VerticalAlignment="Bottom" Height="40"
                                <i:Interaction.Triggers
                                    <i:EventTrigger EventName="Loaded"
                                        <cmd:EventToCommand Command="{Binding ExecuteCommand, Source={StaticResource EventStateDTOViewModel}}" CommandParameter="geteventstates"></cmd:EventToCommand
                                    </i:EventTrigger
                                </i:Interaction.Triggers
                                <Telerik:RadComboBox.ItemTemplate
                                    <DataTemplate
                                        <TextBlock Text="{Binding Name}"  Foreground="{StaticResource MainBrush}" /> 
                                    </DataTemplate
                              </Telerik:RadComboBox.ItemTemplate
                           </Telerik:RadComboBox
                        </Grid
                    </Grid
                </DataTemplate>

1 Answer, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 03 Apr 2012, 03:12 PM
Hi,

I would suggest you to use the SelectedItem together with SelectedValuePath to accomplish this. Here is sample code:
<Telerik:RadComboBox ItemsSource="{Binding EventStateDTOs,Source={StaticResource EventStateDTOViewModel},Mode=TwoWay}"  
              x:Name="comboBoxEventState"
              SelectedItem="{Binding SelectedItem., ElementName=staticDataRadGrid}"
              SelectedValuePath="EventHeader.EventStateID" ...  />

I hope this helps you.

All the best, Ivo
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ComboBox
Asked by
peter
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Share this question
or