Accessing Content Control of a userControl as a radPanel Bar

4 posts, 0 answers
  1. Pranama Moorthy
    Pranama Moorthy avatar
    26 posts
    Member since:
    Jun 2010

    Posted 25 Oct 2010 Link to this post

    Hi Telerik Team,

    I have my RadPanelBar set up as below

    <

     

    UserControl.Resources>

     

     

     

    <core:HierarchicalDataTemplate x:Name="fieldCollectionTemplate" ItemsSource="{Binding fieldCollection}">

     

     

     

    <StackPanel Orientation="Vertical" x:Name="stackPanelForControls">

     

     

     

    <local:SearchFieldControl/>

     

     

     

    </StackPanel>

     

     

     

    </core:HierarchicalDataTemplate >

     

     

     

    </UserControl.Resources>

     

     

     

    <Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleFile}}">

     

     

     

    <Grid.RowDefinitions>

     

     

     

    <RowDefinition Height="*"/>

     

     

     

    <RowDefinition Height="Auto"/>

     

     

     

    </Grid.RowDefinitions>

     

     

     

    <telerikNavigation:RadPanelBar HorizontalAlignment="Left" Margin="8,64,0,32" VerticalAlignment="Stretch" Width="240"

     

     

    ItemsSource="{Binding FieldGroupCollection}" x:Name="searchPanel" Grid.Row="0" IsTextSearchEnabled="True">

     

     

     

    <telerikNavigation:RadPanelBar.ItemTemplate>

     

     

     

    <core:HierarchicalDataTemplate ItemsSource="{Binding fieldCollection}"

     

     

    ItemTemplate="{StaticResource fieldCollectionTemplate}">

     

     

     

    <TextBlock Text="{Binding Name}" Foreground="Blue" />

     

     

     

    </core:HierarchicalDataTemplate>

     

     

     

    </telerikNavigation:RadPanelBar.ItemTemplate>

     

     

     

    </telerikNavigation:RadPanelBar>

     

     

     

    <!--<Button x:Name="btnLoad" Grid.Row="1" Height="50" Width="80" HorizontalAlignment="Left" Content="Load Data"/>-->

     

     

     

    <core:RadButton HorizontalAlignment="Left" Margin="48,0,0,6" VerticalAlignment="Bottom" Content="RadButton" x:Name="btnLoad" Click="btnLoad_Click" />

     

     

     

    </Grid>

     

    </

     

    UserControl>

    I have Created a Search userControl which has a text Box and a ContentControl inside it.

    I need to dynamically go and set the ContentControl in the Search User Control to a Combo Box, Date or checkbox , on a click of a button, but given the template I have, I am not sure, How I can Iterate through the RadPanel Bar to set the contentControl within the UserControl which is a part of the heirarchical DataTemplate. Please advice.

     

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Oct 2010 Link to this post

    Hello Pranama Moorthy,

    Please accept my apology for the delayed response. I prepared a sample project for you  in which you can dynamically set the Content of the ContentControl  by pressing different buttons. Please examine it and let me know if it satisfies your needs.

    Feel free to ask if you need more assistance. We would be glad to help you.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Pranama Moorthy
    Pranama Moorthy avatar
    26 posts
    Member since:
    Jun 2010

    Posted 29 Oct 2010 Link to this post

    Hi Petar,

    I actually dont want to do the action, using a load button, I should want to do it.. when the Item Container is filled up. But the problem is ItemContainer, is virtualized i think, hence it doesnt find its child elements if each of the radpanelBarItem is not in an expanded state.. Could you just show, How I could do it in such a way that it loads automatically the content of the Content Control in the Usercontrol?

  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 03 Nov 2010 Link to this post

    Hello Pranama Moorthy,

    You can implement your logic by handling the ContentControl.Loaded event like in the code snippet below:
    private void contentControl_Loaded(object sender, RoutedEventArgs e)
            {
                (sender as ContentControl).Content = GetComboBox();
            }

    Please give it a try and let me know if this is what you had in mind. If it`s not, please elaborate more on your scenario and we would be glad to assist you further.

    Regards,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top