This is a migrated thread and some comments may be shown as answers.

How do I implement a Close button

3 Answers 137 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Denis Vuyka
Top achievements
Rank 1
Denis Vuyka asked on 30 Dec 2009, 01:21 PM
Hello, can you give me any idea how the "Close" button can be implemented within the header of the item. We need removing items as well adding them ;)

Regards

3 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 30 Dec 2009, 01:48 PM
Hello Denis Vuyka,

Here is a sample code:
XAML:
<Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <DataTemplate x:Key="TileViewItemHeaderTemplate">
                <StackPanel Orientation="Horizontal">
                    <Button Click="Button_Click_1" VerticalAlignment="Center" Content="X"></Button>
                    <TextBlock Text="{Binding}" Margin="5" VerticalAlignment="Center" />
                </StackPanel>
            </DataTemplate>
        </Grid.Resources>
          
            <telerikNavigation:RadTileView x:Name="RadTileView1">
                <telerikNavigation:RadTileViewItem Header="Item1" HeaderTemplate="{StaticResource TileViewItemHeaderTemplate}" ></telerikNavigation:RadTileViewItem>
                <telerikNavigation:RadTileViewItem Header="Item2" HeaderTemplate="{StaticResource TileViewItemHeaderTemplate}"></telerikNavigation:RadTileViewItem>
            </telerikNavigation:RadTileView>
          
    </Grid>

and code behind:

private void Button_Click_1(object sender, RoutedEventArgs e) 
       
           RadTileViewItem itemToRemove = (sender as Button).ParentOfType<RadTileViewItem>(); 
           if (itemToRemove != null
           
               RadTileView1.Items.Remove(itemToRemove); 
           
       }

All the best,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Akku
Top achievements
Rank 1
answered on 24 May 2010, 10:43 AM
Hello Valentin,

I tried the same steps mentioned in your reply about implementing Close Button in Tile.

I am getting an error when i try to close the tile. The difference in your and my RadTileView is, I am adding tiles dynamically.

Below a code snippet of my work:
            //Add Tile Dynamically 
            DataTemplate dtempClose = (LayoutRoot.Resources["CloseButtonTemplate"as DataTemplate); 
            for (int i = 0; i < numberOfTileViews; i++) 
            { 
                RadTileView1.Items.Add(new RadTileViewItem() 
                { 
                    Header = String.Format("TileItem {0}", i), 
                    HeaderTemplate = dtempClose, 
                    Content = new MyTileView() { Text = String.Format("Hello {0}", i)} 
                }); 
            } 
 
        //Close Tile 
        private void CloseTile(object sender, RoutedEventArgs e) 
        { 
            RadTileViewItem itemToRemove = (sender as Button).ParentOfType<RadTileViewItem>(); 
            if (itemToRemove != null
                RadTileView1.Items.Remove(itemToRemove); 
        } 

Error: The given key was not present in the dictionary.

Please guide me in this regards.

Thanks,
Akif Patel
0
Valentin.Stoychev
Telerik team
answered on 27 May 2010, 09:52 AM
Hi Akku,

Sorry for the late response!

I tried to reproduce the problem with the code you sent, but it is all working on our end. Can you send us the complete project in a support ticket so we can investigate where the problem comes from.

Thank you in advance for your cooperation!

Sincerely yours,
Valentin.Stoychev
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.
Tags
TileView
Asked by
Denis Vuyka
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Akku
Top achievements
Rank 1
Share this question
or