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

Hiding 'Restore' button - since 2010.3.1110.1040

15 Answers 321 Views
Window
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 30 Nov 2010, 02:49 PM
Hello,

    There is a difference in command buttons at the top right corner of RadWindow since 2010.3.1110.1040 version.
The 'Restore' button is added (please, see the attached image) so there is 4 buttons now. We use Windows 7 built-in theme.

In previous versions the Maximize button was performing both maximizing and restoring operations.
Now the restore operation is done by 'Restore' button. But we want to keep the behavior from previous builds.

How can we hide the 'Restore' button and assign a command to 'Maximize' button so it works like before
(maximizing and restoring window size)? Altering window template is not doable at the moment, it requires great deal of work.

15 Answers, 1 is accepted

Sort by
0
hwsoderlund
Top achievements
Rank 1
answered on 01 Dec 2010, 09:57 AM
I have noticed this too, but I suspected that it was a problem with our custom template, which we made before Q3. But now I see that it is present in the default template as well. Isn't this a bug? I don't think I have ever seen a window (at least not in MS Windows) with both "maximize" and "restore" available at the same time. It seems to me that the default behaviour of RadWindow should be identical to that in Windows, with the possibility of changing it if/when we need to.

/Henrik
0
Jan
Top achievements
Rank 1
answered on 01 Dec 2010, 11:03 AM
It is possible to simply hide 'Restore' button with the workaround code bellow:

public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
 
            Button button = this.GetTemplateChild("PART_RestoreButton") as Button;
            if (button != null)
            {
                button.Visibility = System.Windows.Visibility.Collapsed;
            }
        }

But then, after maximizing, you can't restore window size by clicking again the 'Maximize' button,
you need to double click the window caption. How to get back the old 'Maximize' button behavior?
0
Jan
Top achievements
Rank 1
answered on 02 Dec 2010, 10:28 AM
I finally got it work:

private Button maximButton;
private Button restoreButton;
 
public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
 
            this.maximButton = this.GetTemplateChild("PART_MaximizeButton") as Button;
            if (this.maximButton != null)
            {
                this.maximButton.Click += new RoutedEventHandler(button_Click);
            }
 
            this.restoreButton = this.GetTemplateChild("PART_RestoreButton") as Button;
            if (this.restoreButton != null)
            {
                this.restoreButton.Click += new RoutedEventHandler(button_Click);
            }
 
            //Initially restore button is hidden.
            this.restoreButton.Visibility = Visibility.Collapsed;
        }
 
        private void button_Click(object sender, RoutedEventArgs e)
        {
            //if maximize button is clicked it should be hidden, while restore button should be visible and the other way around.
            bool isRestoreVisible = sender == this.maximButton;
            if (this.restoreButton != null && this.maximButton != null)
            {
                this.restoreButton.Visibility = isRestoreVisible ? Visibility.Visible : Visibility.Collapsed;
                this.maximButton.Visibility = (!isRestoreVisible) ? Visibility.Visible : Visibility.Collapsed;
            }
        }

A nasty workaround. I hope this will be fixed in one of next releases,
but at least there is a solution for all of us being "conservative" about common window behavior :)
0
hwsoderlund
Top achievements
Rank 1
answered on 02 Dec 2010, 11:04 AM
@Telerik: Please take a look at this issue urgently. I am seeing some really strange behaviour with the restore/maximize functionality when using multiple, stacked windows. Here is what happens:
  1. I open a maximized window.
  2. From that window I open a small (modal) confirmation dialog. In this dialog, the Restore button is enabled, which in my opinion is a bug since there is nothing to restore. This window cannot be maximized, and thus not restored either.
  3. When I click the Restore button in the dialog nothing happens with the dialog window. Instead the maximised window behind the dialog is affected, and thus restored from its maximized state.
  4. At this point, the Restore button in the dialog is hidden, and the Maximize button is shown. If I click maximize now, the restored window in the background is maximized. Again, the dialog window remains unaffected.
I am attaching two screen shots of the situation before and after clicking Restore in the dialog.
Best regards,
/Henrik
0
hwsoderlund
Top achievements
Rank 1
answered on 02 Dec 2010, 11:06 AM
@DCMS
Thanks for the workaround! I will use that until the bugs are fixed.
0
George
Telerik team
answered on 02 Dec 2010, 03:27 PM
Hello Henrik,

Could you please specify if you use a custom theme for the RadWindow? The four buttons should not be visible at the same time. With this Q3 we bound the Visibility of the buttons in the RadWindow header:

<Border x:Name="PART_HeaderButtonsBorder" Grid.Column="1">
 
                                    <StackPanel x:Name="HeaderButtons" Grid.Column="1" Margin="0 0 3 0" Orientation="Horizontal">
 
                                        <telerik:RadButton x:Name="PART_MinimizeButton" Command="telerik:WindowCommands.Minimize" Style="{StaticResource WindowButtonStyle}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}">
 
                                            <Path Data="M1.5,7.5 L12.5,7.5 12.5,11.5 1.5,11.5 Z" Fill="{StaticResource WindowButtonIconFill}" Height="14" Stroke="{StaticResource WindowButtonIconStroke}" Width="14"/>
 
                                        </telerik:RadButton>
 
                                        <telerik:RadButton x:Name="PART_RestoreButton" Command="telerik:WindowCommands.Restore" Style="{StaticResource WindowButtonStyle}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}">
 
                                            <Path Data="M0.5,4.5 0.5,11.5 1.5,12.5 8.5,12.5 9.5,11.5 9.5,3.5 1.5,3.5 Z M3.5,6.5 L3.5,9.5 L6.5,9.5 6.5,6.5 Z M3.5,3.5 3.5,1.5 4.5,0.5 11.5,0.5 12.5,1.5 12.5,9.5 11.5,10.5 9.5,10.5 9.5,3.5 Z" Fill="{StaticResource WindowButtonIconFill}" Height="14" Stroke="{StaticResource WindowButtonIconStroke}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}" Width="14"/>
 
                                        </telerik:RadButton>
 
                                        <telerik:RadButton x:Name="PART_MaximizeButton" Command="telerik:WindowCommands.Maximize" Style="{StaticResource WindowButtonStyle}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}">
 
                                            <Path Data="M1.5,2.5 L12.5,2.5 12.5,11.5 1.5,11.5 Z M4.5,5.5 L9.5,5.5 9.5,8.5 4.5,8.5 Z" Fill="{StaticResource WindowButtonIconFill}" Height="14" Stroke="{StaticResource WindowButtonIconStroke}" Width="14"/>
 
                                        </telerik:RadButton>
 
                                        <telerik:RadButton x:Name="PART_CloseButton" Command="telerik:WindowCommands.Close" Style="{StaticResource WindowButtonStyle}" Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}">
 
                                            <Path Data="M1.5,3.5 L2.5,2.5 4.5,2.5 6.5,4.5 8.5,2.5 10.5,2.5 11.5,3.5 8.5,6.5 8.5,7.5 11.5,10.5 10.5,11.5 8.5,11.5 6.5,9.5 4.5,11.5 2.5,11.5 1.5,10.5 4.5,7.5 4.5,6.5 z" Fill="{StaticResource WindowButtonIconFill}" Height="14" Stroke="{StaticResource WindowButtonIconStroke}" Width="14"/>
 
                                        </telerik:RadButton>
 
                                    </StackPanel>
 
                                </Border>

I would recommend you to update your custom template.

Please do not hesitate to contact us if you require any further information.



Kind regards,
George
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
hwsoderlund
Top achievements
Rank 1
answered on 03 Dec 2010, 09:59 AM
The issue does not have to do with the custom template, it is definitely something else. We do use a custom template, but we had already changed that to include the changes in Q3. In fact, I just tried removing the custom template altogether and the restore button is still visible, both with the standard Telerik theme and the Windows7 theme. See the attached screen shot (using the Windows7 theme, no custom template).

I have spent some time now trying to reproduce the issue in a sample project, but so far unsuccessfully. I have replicated our scenario as closely as possible, with all the properties and handlers that we use in our production code, but in the sample project everything works fine. You can clearly see in the screen shot that there is a problem, though. The button is visible, and I am not crazy. :) I am thinking that I may have to use the workaround described by DCMS after all since I cannot find a way to reproduce the bug.

Best regards,
/Henrik

0
Miroslav Nedyalkov
Telerik team
answered on 08 Dec 2010, 10:51 AM
Hello Henrik,

 We cannot reproduce the problem with the default themes as well so we cannot fix the problem. Please let us know if you are able to reproduce it in a project that you can send us. This would help us find and fix the issue.

Best wishes,
Miroslav Nedyalkov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
hwsoderlund
Top achievements
Rank 1
answered on 08 Dec 2010, 11:21 AM
I will let you know if I come up with something, but at the moment it is not looking good. I have no idea where to start. This is the weirdest error...
0
Pana
Telerik team
answered on 14 Dec 2010, 08:31 AM
Hi,

The old pre Q3 themes used VSM to show/hide buttons. The new version uses Commands and their 'CanExecute' value to determine whether the buttons should be visible or not.

To upgrade from old versions to the new you should:
1) For the 4 window buttons set the Commands:

Command="telerik:WindowCommands.Minimize"
Command="telerik:WindowCommands.Restore"
Command="telerik:WindowCommands.Maximize"
Command="telerik:WindowCommands.Close"

2) Replace Buttons with RadButtons.
3) Add the binding to each of them:
Visibility="{Binding IsEnabled, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource Self}}"
So far if a button can not be used (like a maximize button on a maximized window) it will get disabled by the command and then it will disappear because of the visibility binding.

Old themes or custom themes or styles or implicit styles should be upgraded.
Note that having the window.xaml in your project does is not the only indication of having an old theme. if you upgrade Telerik.Windows.Controls.* dlls you should also upgrade the Telerik.Themes.* to the same release version. Also make sure that all your projects are targeted at the same framework (no mismatch SL3/SL4).

@Henrik Söderlund: You sure do have a custom style for the RadWindow. At least we do not have that fancy radial X button

For the rest of you - Creating a simple project using the telerik project template, importing the Telerik.Windows.Controls, Telerik.Windows.Controls.Input and Telerik.Windows.Themes.Windows7 references and launching a RadWindow - looks fine. So if you are experiencing the issue it should either be somewhat outdated style making it into your projects or somewhat advanced glitch that messes up with the commands. Unfortunately the last is not easily reproduced.

If someone can send a project that reproduces the issue I would gladly take a look.

All the best,
Pana
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
hwsoderlund
Top achievements
Rank 1
answered on 14 Dec 2010, 09:35 AM
If you look at the 2nd screen shot I posted (radwindowbug-03.PNG) you will see that it is taken when I had removed our custom style completely and just used the Windows7 theme as is. And both buttons were still visible. I am 100% sure that my dll:s were up to date at the time. The new screen shot I am posting now is taken today, with the dll:s from the latest internal build (13 December). I am now using the default Telerik theme and I have double-checked that I am using the correct dll:s. And both buttons are still visible.

So I am pretty sure that what I am seeing is the "advanced glitch" you are talking about. I have tried mimicking our scenario as closely as possible in a sample project, but so far I cannot reproduce the bug. At the moment I am using the following workaround to hide the buttons:

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
 
namespace GLS.Gui.Helper
{
    public class GLSWindow : RadWindow
    {
        private Button _RestoreButton;
        private Button _MaximizeButton;
 
        public GLSWindow()
        {
            DefaultStyleKey = typeof(RadWindow);
 
            this.Loaded += GLSWindow_Loaded;
        }
 
        void GLSWindow_Loaded(object sender, RoutedEventArgs e)
        {
            //Dispatch to make sure that the buttons are available when the code executes
            Dispatcher.BeginInvoke(() => AdjustButtonsToWindowState());
 
            this.Loaded -= GLSWindow_Loaded;
        }
 
        private void AdjustButtonsToWindowState()
        {
            if (_MaximizeButton != null && _RestoreButton != null)
            {
                if (this.WindowState == WindowState.Maximized)
                {
                    _MaximizeButton.Hide();
                    _RestoreButton.Show();
                }
                else if (this.WindowState == System.Windows.WindowState.Normal)
                {
                    _MaximizeButton.Show();
                    _RestoreButton.Hide();
                }
            }
        }
 
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();
 
            _MaximizeButton = this.GetTemplateChild("PART_MaximizeButton") as Button;
            _RestoreButton = this.GetTemplateChild("PART_RestoreButton") as Button;
        }
 
        protected override void OnWindowStateChanged(RoutedEventArgs args)
        {
            base.OnWindowStateChanged(args);
 
            AdjustButtonsToWindowState();
        }
    }
}
0
Pana
Telerik team
answered on 14 Dec 2010, 10:13 AM
Hello,

Is there any chance that you can send me your complete project so we can try to find what is causing the problem? You can do that in a support ticket where the project will not be visible to other clients and we can also sign NDA.

Kind regards,
Pana
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
hwsoderlund
Top achievements
Rank 1
answered on 14 Dec 2010, 12:23 PM
I will have to ask my boss before I do something like that. He will be back in a few days. The thing is, though, you would need the entire database as well, along with wcf services, folder structures, configuration files, etc. etc. But I will talk to my boss and see what he says. And I will try again and see if I can isolate it to a sample project instead. That would be so much easier.

Thanks for your help.
/Henrik
0
Pana
Telerik team
answered on 14 Dec 2010, 01:27 PM
Hi,

Sample project would be perfect. If you can not do it however you can also try to remove parts of your solution that are not required to reproduce the issue. For example if you are using a database with login screen, user authentication etc. etc. but the issue is visible when you open a certain window you can just put a big button on the mainpage that opens the buggy window without the need to connect to DB. After all we are interested in reproducing the bug so you can send just part of the project. And it will be ok as far as we can build and run the problem here.

Kind regards,
Pana
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
James
Top achievements
Rank 1
answered on 05 Jan 2011, 02:34 PM
Hi George,

I just updated telerik DLL to the latest stable version. I had the same issue where RadWindow header buttons where visible regardless of RadWindow settings.

I am using custom template, and the template you have supplied here helped me solve the issue.

Thanks once again for best support :)

Regards, Bhavin 
Tags
Window
Asked by
Jan
Top achievements
Rank 1
Answers by
hwsoderlund
Top achievements
Rank 1
Jan
Top achievements
Rank 1
George
Telerik team
Miroslav Nedyalkov
Telerik team
Pana
Telerik team
James
Top achievements
Rank 1
Share this question
or