controls inside TileView

3 posts, 0 answers
  1. kannan
    kannan avatar
    42 posts
    Member since:
    Sep 2010

    Posted 22 Nov 2010 Link to this post

    Hi,
     I have some controls inside Tileview.like RadChart present inside TileView , and checkbox present inside RadChart. so i want to get the name of checkbox in TileView_TileStateChanged event..
    TileView
           |_RadChart
                    |_CheckBox

    Thanks In Advance,
    kannan.s

     

  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 23 Nov 2010 Link to this post

    Hi kannan,

    You can use the VisualTreeHelper class or our extension method ChildrenOfType.

    <telerik:RadTileView TileStateChanged="RadTileView_TileStateChanged">
        <telerik:RadTileViewItem Header="Item 0">
            <CheckBox x:Name="targetCheckBox" Content="Target" HorizontalAlignment="Center"
                    VerticalAlignment="Center" />
        </telerik:RadTileViewItem>
        <telerik:RadTileViewItem Header="Item 1"></telerik:RadTileViewItem>
        <telerik:RadTileViewItem Header="Item 2"></telerik:RadTileViewItem>
    </telerik:RadTileView>

    private void RadTileView_TileStateChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        RadTileViewItem item = e.OriginalSource as RadTileViewItem;
        CheckBox targetCheckBox = item.ChildrenOfType<CheckBox>().Where(checkbox => checkbox.Name == "targetCheckBox").FirstOrDefault();
        if (targetCheckBox != null)
        {
            MessageBox.Show("Target found");
        }
    }

    Please bear in mind that traversing the visual tree up and down will have a performance impact on your application, so choose wisely.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. kannan
    kannan avatar
    42 posts
    Member since:
    Sep 2010

    Posted 23 Nov 2010 Link to this post

    Hi Kiril Stanoev,

         Thanks for your reply. it is working fine..
Back to Top