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

How to hide minimize button

4 Answers 130 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Licenses
Top achievements
Rank 1
Licenses asked on 31 Aug 2010, 06:30 PM
Hello,

Is there a way to hide the minimize button in case of a MaximizedMode="One". This button doesn't do anything, so there is no use in showing it. I've tried to change the template for a TileViewItem, but this doesn't seem to work.

Any suggestions?

Thanks,
Sodi

4 Answers, 1 is accepted

Sort by
0
Licenses
Top achievements
Rank 1
answered on 31 Aug 2010, 06:38 PM
I've tried looking for the maximized buttons via the code provided in the Telerik demo's, but this gives me a ArgumentOutOfRangeException when I do:visualRoot.FindName("MaximizeToggleButton")

private void GetMaximizeButtons(){
   for (int i = 0; i < this.tileView1.Items.Count; i++){
      RadTileViewItem tileViewItem = this.tileView1.ItemContainerGenerator.ContainerFromIndex(i) as RadTileViewItem;
      if (tileViewItem != null){  
         Panel visualRoot = VisualTreeHelper.GetChild(tileViewItem, 0) as Panel;
       if (visualRoot != null) {
              ToggleButton maximizedToggleButton = visualRoot.FindName("MaximizeToggleButton") as ToggleButton;
               if (maximizedToggleButton != null){
              this.toggleButtons.Add(i, maximizedToggleButton);
                     if (i == 0) {
                        maximizedToggleButton.Opacity = 0.0;
              }
        }
    }
}

Is there maybe another way to find the togglebuttons so I can set the opacity to 0 when the tasktile is maximized? I can reach the taskTileItems directly via codebehind by their names. Maybe this can make the code a bit easier.
0
Accepted
Tina Stancheva
Telerik team
answered on 03 Sep 2010, 01:36 PM
Hello Sodi We,

In your scenario it is best to apply different styles to the Maximized and Minimized items, like in the attached example.

However, if you prefer to control the Opacity of the button from code-behind you should keep in mind that during the initialization of the items, the MaximizeToggleButton element isn't initialized and you won't be able to access it. Therefore this approach is only applicable when the Items collection is generated and initialized. Then the TileStateChanged() event can be handled to control the opacity of the MaximizeToggleButton element like so:
private void myTileView_TileStateChanged(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    RadTileViewItem item = e.Source as RadTileViewItem;
    ToggleButton maximizeToggleButton = item.FindChildByType<ToggleButton>();
 
    if (maximizeToggleButton != null)
    {
        if (item.TileState == TileViewItemState.Maximized)
        {
            maximizeToggleButton.Opacity = 0;
        }
        else
        {
            maximizeToggleButton.Opacity = 1;
        }
    }
}
However, if you decide to use this approach, you will need to manually apply a different style (without the MaximizeToggleButton) to the initially maximized item. Therefore I would suggest you to go with the first approach, illustrated in the attached project.

Sincerely yours,
Tina Stancheva
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
0
Ian
Top achievements
Rank 1
answered on 29 Sep 2010, 01:45 PM
When I run the sample project you have provided I still get a minimize button, as indicated on the screen capture I have taken:

Screencapture still shows Minimize button

What have I missed?  Would really like to hide this but the code provided doesn't appear to do that?
0
Licenses
Top achievements
Rank 1
answered on 29 Sep 2010, 01:48 PM
Well in fact this sample demonstrates two approaches. You can choose the approach by commenting out the other approach. I've chosen to comment out myTileView1 in MainPage.xaml and everything works like a charm.
Tags
TileView
Asked by
Licenses
Top achievements
Rank 1
Answers by
Licenses
Top achievements
Rank 1
Tina Stancheva
Telerik team
Ian
Top achievements
Rank 1
Share this question
or