How to hide minimize button

5 posts, 1 answers
  1. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 31 Aug 2010 Link to this post

    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
  2. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 31 Aug 2010 Link to this post

    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.
  3. DevCraft banner
  4. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Sep 2010 Link to this post

    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
  5. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 29 Sep 2010 Link to this post

    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?
  6. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 29 Sep 2010 Link to this post

    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.
Back to Top
DevCraft banner