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" 
                                <RowDefinition Height="Auto"/> 
                            <Grid Margin="8,8,0,0" d:LayoutOverrides="Height"
                                    <ColumnDefinition Width="150" /> 
                                    <ColumnDefinition Width="*" /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                               <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:EventTrigger EventName="Loaded"
                                            <cmd:EventToCommand Command="{Binding ExecuteCommand, Source={StaticResource EventStateDTOViewModel}}" CommandParameter="geteventstates"></cmd:EventToCommand
                                            <TextBlock Text="{Binding Name}"  Foreground="{StaticResource MainBrush}" /> 
  2. Ivo
    Ivo avatar
    390 posts

    Posted 03 Apr 2012 Link to this post


    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}"  
                  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 >>
Back to Top