We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

TitleBar extra buttons

Thread ID:

Created:

Updated:

Platform:

Replies:

125622 Aug 29,2016 07:59 AM Sep 1,2016 12:42 AM WPF 6
loading
Tags: Ribbon
Luís Rodrigues
Asked On August 29, 2016 07:59 AM

i have a RibbonWindow with a Ribbon.

On my Window's Loaded exvent I have the following code:

WindowTitleBarButton HelpButton = null;

var titleBar = VisualUtils.FindDescendant(sender as RibbonWindow, typeof (TitleBar)) as TitleBar;

if (titleBar != null)

HelpButton = titleBar.Template.FindName("HelpButton", titleBar) as WindowTitleBarButton;

if (HelpButton != null)

{

HelpButton.Click += HelpButton_Click;

HelpButton.ToolTip = "Help";

}


However, HelpButton is always null - even though the button does show up

Luís Rodrigues
Replied On August 29, 2016 08:44 AM

Ok

Moving that peice of code to my Ribbon's Loaded event rather then RibbonWindow loaded fixed my issue.
Now HelpButton is no longer null

However, Ribbon's Loaded event fires twice which means i end up assigne the Helpbutton's event twice

I'll have to add a check to only run that piece of code on first time Loaded fires

Mariappan S [Syncfusion]
Replied On August 30, 2016 02:05 AM

Hi Luís, 

Thanks for your update 

Query: “Ribbon's Loaded event fires twice which means i end up assigne the Helpbutton's event twice” 

Can you please explain your query clearly and also let us know if you need any other assistance for this? 

Regards, 
Mariappan S. 


Luís Rodrigues
Replied On August 30, 2016 04:09 AM

Let me try to explain it

I'm using the Ribbon Control in my project. The Ribbon Control has a 'Loaded' event. so i created an event handler for the Ribbon's Loaded event and placed the code that assigns an event handler to the HelpButton's Click event in it.

Problem is, Ribbon's Loaded event fires twice - so i ended up assigning the HelpButton's Click event twice.

That means, when i clicked the ? button, It would also run my event handler twice - so if my HelpButton's Click event Handler would open Google,com in a browser, there would be two browser windows/tabs per click.

My solution was to add a signal field so i would know i was on my second Ribbon Loaded event firing.

Something like:

 if (!_set)
 {

WindowTitleBarButton HelpButton = null;

var titleBar = VisualUtils.FindDescendant(sender as RibbonWindow, typeof (TitleBar)) as TitleBar;

if (titleBar != null)

HelpButton = titleBar.Template.FindName("HelpButton", titleBar) as WindowTitleBarButton;

if (HelpButton != null)

{

HelpButton.Click += HelpButton_Click;

HelpButton.ToolTip = "Help";

}

_set = true;

}


Mariappan S [Syncfusion]
Replied On August 31, 2016 06:07 AM

Hi Luís   
   
Thanks for your update.   
   
We have prepared simple Ribbon sample with Loaded event. But we were unable to reproduce the reported issue. In this sample, Ribbon Loaded eventgets fired only once.   
   
Please download the sample from the below link.   
   
Sample link: RibbonSample
 
   
If the issue still persist, could you please provide more information or reproducible sample. It would be very helpful for us to resolve your problem at the earliest.   
   
Regards,   
Mariappan S. 


Luís Rodrigues
Replied On August 31, 2016 01:16 PM

Hi

Kept thinkiring on this since it made no sense to fire twice and i figured it out

The Ribbon's Loaded get's fired again every time i apply a new theme
I'm giving users the option to switch theme on the fly

I now don't need that _set field anymore since i simply removed the event handler before applying the new theme
This makes it so that when Loaded fires again due to the change of theme, it's no problem to add the handler again

So far it seams to have fixed it

Mariappan S [Syncfusion]
Replied On September 1, 2016 12:42 AM

Hi Luís, 

Thanks for your information 

Please let us know if you need further assistance. 

Regards, 
Mariappan S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;