Binding a RadCombobox in the ItemTemplate of a RadMenuItem

2 posts, 0 answers
  1. Dave Swersky
    Dave Swersky avatar
    5 posts
    Member since:
    Apr 2010

    Posted 15 Dec 2010 Link to this post

    Hello,

    I have a UserControl with a Radmenu in it.  Here is the markup:

    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
             <telerik:RadMenu.Background>
          <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
          <GradientStop Color="#FF9D9D9D" Offset="1"/>
          <GradientStop Color="White"/>
          </LinearGradientBrush>
          </telerik:RadMenu.Background>
            <telerik:RadMenuItem Header="New" />
            <telerik:RadMenuItem Header="Edit" />
            <telerik:RadMenuItem Header="Delete" />
    <telerik:RadMenuItem>
    <telerik:RadMenuItem.HeaderTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>
    <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
    </ComboBox>
    </StackPanel>
    </DataTemplate>
    </telerik:RadMenuItem.HeaderTemplate>
    </telerik:RadMenuItem>
    <telerik:RadMenuItem Header="First" />
    <telerik:RadMenuItem Header="Next" />
            <telerik:RadMenuItem Header="Previous" />
    <telerik:RadMenuItem Header="Last" />
           </telerik:RadMenu>
    <telerik:RadMenu HorizontalAlignment="Left" VerticalAlignment="Top" x:Name="UserManagementMenu" DataContext="{Binding}">
                        <telerik:RadMenu.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF9D9D9D" Offset="1"/>
                                <GradientStop Color="White"/>
                            </LinearGradientBrush>
                        </telerik:RadMenu.Background>
                        <telerik:RadMenuItem Header="New" />
                        <telerik:RadMenuItem Header="Edit" />
                        <telerik:RadMenuItem Header="Delete" />
                        <telerik:RadMenuItem>
                            <telerik:RadMenuItem.HeaderTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Text="User Search:"></TextBlock>     
                                        <ComboBox x:Name="cmbUserSearch" ItemsSource="{Binding AllUsers, Mode=TwoWay}" VerticalAlignment="Center" Width="125" Margin="2">
                                        </ComboBox>
                                    </StackPanel>                              
                                </DataTemplate>
                            </telerik:RadMenuItem.HeaderTemplate>
                        </telerik:RadMenuItem>
                        <telerik:RadMenuItem Header="First" />
                        <telerik:RadMenuItem Header="Next" />
                        <telerik:RadMenuItem Header="Previous" />
                        <telerik:RadMenuItem Header="Last" />
                    </telerik:RadMenu>

    I have a RadCombobox called "cmbUserSearch" in the HeaderTemplate of one of the menu items, which displays but does not populate.

    The DataContext of the UserControl (my ViewModel) has a generic List<string> property called "AllUsers".  That property calls a  RaisePropertyChanged("AllUsers") method in the setter.  When I debug, I see the data coming in from the RIA services request and the value is set on the property, but the control does not populate.  I think it must be a binding problem but I can't figure out the right syntax.  Please help.  

    Thanks!

    Dave Swersky
  2. Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 17 Dec 2010 Link to this post

    Hi Dave Swersky,

    Could you send sample project where we can reproduce this issue?

    Regards,
    Hristo
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
Back to Top