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

Overflow not working when hosted in Excel addin

4 Answers 74 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
klac
Top achievements
Rank 1
klac asked on 02 Feb 2016, 11:23 PM

I'm using a RadToolBar in an Excel task pane. When the task pane is sized to move controls to the overflow, the overflow button will enable but clicking the overflow button will not display the controls. I've further narrowed the problem to when the WPF user control is converted to an INativeControlHandle and back before adding it to the task pane.

 

I've built a sample project to demonstrate the problem. The sample also includes a regular WPF ToolBar which does not have the same problem. (remove the .jpg extension from the .zip file)

 

Note that the same code hosted in a Word addin will function correctly as will a generic WinForms application.

 

Any advice would be appreciated.

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 05 Feb 2016, 04:42 PM
Hello Kahn,

I can confirm the describe behavior also on my side. It comes from the fact that the Popup element that holds the toolbar's overflow lost focus right after it got it. This closes the popup. However, I will need time to further investigate your scenario. I will contact you in few days with more information on the matter.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
klac
Top achievements
Rank 1
answered on 05 Feb 2016, 05:20 PM
Thanks Martin.
0
Martin Ivanov
Telerik team
answered on 10 Feb 2016, 04:41 PM
Hi Kahn,

I spent some time to investigate the reported behavior and I can't tell that I am absolutely sure what is causing it. However, it seems that the Excel cells are getting the focus from the other elements. On the other hand the overflow of the toolbar is displayed in a Popup element which closes when lost its focus. Basically, clicking on the overflow button, the popup opens for a fragment of the second and then almost right away it closes because the focus is lost.

This behavior can be observed also with native WPF components as ToggleButton and a Popup which IsOpen property is bound to the ToggleButton's IsChecked.
<Grid>
    <ToggleButton x:Name="btn1" Content="Btn" Width="100" Height="100"/>
    <Popup StaysOpen="False" Focusable="False"
                   IsOpen="{Binding ElementName=btn1, Path=IsChecked}" AllowsTransparency="True">
        <TextBlock Text="Test" />
    </Popup>
</Grid>
You can also try to type into a WPF TextBox element - the focus will be sent to the selected Excel cell.

As you mentioned this behavior appears only after the UserControl is converted to a contract and vice versa. Note that ContractToViewAdapter() won't return the same user control as the one passed in the ViewToContract() method, but an object of type HwndHost that wraps it and which might causing the issue. In addition the WPF Add-Ins Overview MSDN article talks about the removing isolation boundaries between the host application and the add-in when using the FrameworkElementAdapters class which might be related to the issue. I recommend you to check if there is anything similar discussed in StackOverflow or any other .NET community that concerns the FrameworkElementAdapters class and see if there is a solution for this behavior.

As a workaround you can avoid using the FrameworkElementAdapters. Or you can use the ChildrenOfTypeExtensions.ChildrenOfType<T>() extension method to get the Popup of the RadToolBar control. Then set its StaysOpen property to True and close the popup manually, when necessary. You can control the visibility of the overflow popup using the toolbar's IsOverflowOpen property.

I hope this information is useful.

Regards,
Martin
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
klac
Top achievements
Rank 1
answered on 10 Feb 2016, 04:49 PM

Thanks for your help. It's much appreciated.

 

Tags
ToolBar
Asked by
klac
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
klac
Top achievements
Rank 1
Share this question
or