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

BackStage View Show By Code

11 Answers 363 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
M_M
Top achievements
Rank 1
M_M asked on 08 May 2011, 01:44 PM
how can i activate (show) a specific tab in backstage view using code just by code ? (like when u press ctrl+p in microsoft word, it brings up "Print Preview Backstage")

11 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 10 May 2011, 04:58 PM
Hi vbearn vb,

There are two approaches to achieve this. The first one is by using our shortcut mechanism:
this.backstageTabPrintPreview.Shortcuts.Add(new RadShortcut(Keys.Control, Keys.P));

This will simulate a click on the item whenever you press Control + P keys.

The second approach concerns the usage of RadRibbonBarBackstageView's SelectedItem property:
this.myBackstageView.SelectedItem = this.backstageTabPrintPreview;

I hope you find this helpful. Feel free to contact me if you have any additional questions.

Greetings,
Ivan Todorov
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
M_M
Top achievements
Rank 1
answered on 15 May 2011, 01:28 PM
thanks for ur reply admin.
due to restrictions in my app, i cant use first approach, because most of the times Backstage must be triggered in source code (e.g. in click event of a button). i like something like second approach, but just setting SelectedItem of backstage will not bring up backstageview. actually nothing happens when i just set SelectedItem = ... (consider that the backstage had not been opened yet, i want to open backstage first, and then select my appropriate tab)

i used a block of code like this for my purpose:

frmMain.Instance.RibbonBar.BackstageControl.SelectedItem = frmMain.Instance.backstageTabReport;
frmMain.Instance.RibbonBar.BackstageControl.ShowPopup(
    new System.Drawing.Point(2, 35), frmMain.Instance.RibbonBar.RibbonBarElement);

   and backstage showed. but sometimes backstage is shown and simply not any tab is selected (it is just an empty white screen) so i added this after my last code:

frmMain.Instance.RibbonBar.BackstageControl.BackstageElement.SuspendLayout();
frmMain.Instance.RibbonBar.BackstageControl.BackstageElement.ResumeLayout(true, true);

it seems to work out ok. i just needed to know if there is any other convenient way to do this? my solution doesnt seem bugproof.
0
Ivan Todorov
Telerik team
answered on 18 May 2011, 04:47 PM
Hello M_M,

I was not able to reproduce the described issue. There might be something specific in your project that is causing it. However, I would suggest you to set the selected item after you have shown the backstage. Please let me know if this works. If not, I would kindly ask you to post here a code sample that reproduces the issue. This will help me to locate the issue and provide you with accurate support.

I am looking forward to your reply.

Greetings,
Ivan Todorov
the Telerik team
Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
0
Markus
Top achievements
Rank 1
answered on 02 Nov 2011, 03:15 PM
HI there,

same issue over here: How do I programmatically show the Backstage View?
Setting the selected item does not do anything. Using M_M's solution leads to layout errors on the ribbon bar...

Greetings,

Markus
0
Ivan Todorov
Telerik team
answered on 03 Nov 2011, 04:12 PM
Hi Markus,

M_M's solution uses the same code that is internally used to show the backstage view, so there should not be any issues with it. Please describe what kind of errors you are experiencing. You can also post the code you are using, so I can test it and reproduce them. This will let me provide you with more accurate answers.

I am looking forward to your reply.

Greetings,
Ivan Todorov
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Drakemar
Top achievements
Rank 1
answered on 21 Dec 2011, 05:48 PM
Hello,

I'm facing the same issue.  I've created a RadRibbonForm with ApplicationMenuStyle = BackstageView.  When I start the application the BackstageView does not appear, and I have to click the tab in the top left to activate it.

I've been able to get it to show, sometimes, by programmatically setting the BackstageTabItem.  However, it no longer seems to work.  Additionally, this was working, the BackstageView would not be expanded and caused a layout issue.  Clicking on the tab would resolve the layout, but this is not desired.

Therefore, what I want to achieve is to have the BackstageView open on runtime, autosized, and have the tab highlighted.  However, I cannot manage to find a way to do this.

A couple other notes:
  1. The events for BackstageViewOpened and Opening don't seem to work at all.
  2. Is it possible to show the nice round graphical image in the TopLeft in BackstageView mode?

Thank you.


0
Ivan Todorov
Telerik team
answered on 23 Dec 2011, 11:22 AM
Hello,

There really seems to be some issues in this scenario with BackstageView since there are already three people who have complained about it. However, we are still not able to reproduce them and none of the people who wrote in this thread have sent a sample which demonstrates the issues. We will be grateful if you can demonstrate your scenario in a sample project. This will let us investigate it and provide you with adequate support. Please note that you have to open a new support ticket from Your Account in order to be able to attach files.

As to your additional questions, I have tested the BackstageViewOpening / Opened events and they seem to fire properly in all cases. As to changing the style of the corner button, here is how you can achieve this:
public Form1()
{
    InitializeComponent();
    this.radRibbonBar1.RibbonBarElement.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);         
    this.radRibbonBar1.RibbonBarElement.ApplicationButtonElement.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
    this.radRibbonBar1.RibbonBarElement.QuickAccessToolBar.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
    RadQuickAccessToolBar.InnerItem item = this.radRibbonBar1.RibbonBarElement.QuickAccessToolBar.GetInnerItem();
    if (item != null)
        item.SetValue(RadRibbonBarElement.IsBackstageModeProperty, false);
}

I hope this will help you. I am looking forward to hearing from you.

All the best,
Ivan Todorov
the Telerik team

Q3’11
of RadControls for WinForms is available for download (see what's new). Get it today.
0
Drakemar
Top achievements
Rank 1
answered on 23 Dec 2011, 03:21 PM
Thank you for the reply, Ivan. The code to make the rounded button works very nicely.

The events for opening closing are unrelated to the controls themselves, it was a source control issue. So, you can safely ignore these as issues.

Finally, at your request I opened a ticket for this issue (#495839)  in which I've added a sample project. 


Sincerely,

Mark
0
Ivan Todorov
Telerik team
answered on 28 Dec 2011, 02:44 PM
Hello Drakemar,

Thank you for opening a support ticket and providing us with a sample project. You can check my reply in that support ticket.

I will post some updates on this case here, so the community can benefit from it too:

By design, the BackstageView should be opened only when the form has been displayed. Therefore, opening the BackstageView programatically in the form's constructor will result in an incorrect layout. To overcome this, you should show the BackstageView in the form's OnShow event. Additionally, there seems to be an issue with RadRibbonForm and BackstageView when the form is maximized. This issue is logged in PITS and can be found at this link. To workaround it, you need to handle the SizeChanged event of the form and recalculate the proper position of the BackstageView. The following code snippet demonstrates this:

public Form1()
{
    InitializeComponent();
    this.SizeChanged += new System.EventHandler(MainForm_SizeChanged);
}
  
public Point GetBackstageLocation()
{
    Point location = radRibbonBar1.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location;
    location.Offset(new Point(0, radRibbonBar1.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height));
    location.Offset(radRibbonBar1.Location);
  
    return location;
}
  
void MainForm_SizeChanged(object sender, System.EventArgs e)
{
    if (radRibbonBar1.BackstageControl != null && radRibbonBar1.BackstageControl.IsShown)
    {
        radRibbonBar1.BackstageControl.Location = GetBackstageLocation();
    }
}
  
protected override void OnShown(System.EventArgs e)
{
    base.OnShown(e);
    radRibbonBar1.BackstageControl.ShowPopup(GetBackstageLocation(), radRibbonBar1.RibbonBarElement);
}

I hope this will help you. In case you have any further questions, do not hesitate to write back.

Regards,
Ivan Todorov
the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Drakemar
Top achievements
Rank 1
answered on 28 Dec 2011, 03:42 PM
Thank you very much for the support.  The code presented does the job :)

Sincerely,

Mark
0
Stefan
Telerik team
answered on 28 Dec 2011, 03:49 PM
Hi,

I am glad we could help. Should you have any other questions, do not hesitate to contact us.

Regards,
the Telerik team
Tags
RibbonBar
Asked by
M_M
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
M_M
Top achievements
Rank 1
Markus
Top achievements
Rank 1
Drakemar
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or