Ribbon with popup control

Feb 11, 2015 at 2:40 AM
I know i can popup a wpf form when a ribbon button is clicked, but i would like to instead add a ribbon button that when clicked, pops out a calendar control. Can this done with ExcelDNA?
Alternatively, is it possible to center the form on the ribbon button that is clicked?
Coordinator
Feb 11, 2015 at 1:21 PM
Edited Feb 11, 2015 at 1:23 PM
There's no integrated Calendar control in the Office ribbon, and there's no extensibility to add some kind of user control. One might be able to fake it with some galleries, though I haven't seen anything like it.

To find the screen location of a ribbon button, one could try the Windows UI Automation tools, though that's quite a complicated story to figure out. This found a few hits on Google: "windows ui automation office ribbon"

-Govert
Feb 12, 2015 at 4:14 AM
thank you govert. i will research further.
Feb 12, 2015 at 7:35 PM
Edited Feb 12, 2015 at 7:39 PM
Hi Govert,

Do you have an example of launching WPF window as pop up by clicking on a ribbon button? I am using c# as the programming language. A sample example will really help.

I have seen this thread https://exceldna.codeplex.com/discussions/266302 on showing wpf window but i am really struggling without a complete sample.

Also I have to say what you have produce is super!!

thanks
Feb 12, 2015 at 7:39 PM
Hi dizzy0ny,

I would really appreciate if you can give me a sample example of what you did. Would really appreciate this. I have seen this thread https://exceldna.codeplex.com/discussions/266302 on showing wpf window but i am really struggling without a complete sample.

Regards

Shuhed
Feb 13, 2015 at 4:24 AM
Hi Shuhed...i did not do anything too special. really i just created a WPF form with a calendar control and in handler for the ribbon button, i simply show the window as a modal dialogue.
Feb 13, 2015 at 8:18 AM
Hi dizzy0ny,

Did you create the wpf as user control library or wpf window as a separate project ? and then did you reference this in your ribbon project? I created the wpf window project and compiled it as a class library and then reference the assembly in ribbon project but i am getting error namespace or directive not found: I've added the reference in the ribbon project and in the dna file.

There must be something i've missed. Appreciate if you can help:

here is my code snippet:

using TestWpfApplication;
    public void ShowWindow()
    {
        thread = new Thread(doWork);
        thread.SetApartmentState(ApartmentState.STA);
        thread.IsBackground = true;
        thread.Start();
    }

    private static void doWork()
    {

        TestWpfApplication.MainWindow win = new TestWpfApplication();
        win.Show();
        win.Closed += (sender1, e1) => win.Dispatcher.InvokeShutdown();
        System.Windows.Threading.Dispatcher.Run();



    }
Feb 13, 2015 at 10:25 AM
Hi dizzy0ny/Govert

I was able to get the wpf popup working. I am displaying the dialogue as modal. One more question is how do I talk back to excel?

Thanks

Shuhed