Radcombox within a datatemplate not binding

2 posts, 0 answers
  1. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 29 Mar 2012 Link to this post

    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>
  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 03 Apr 2012 Link to this post

    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 >>
  3. DevCraft banner
Back to Top