Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DockablePane hosting chromium browser in WPF page breaks desired functionality

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
dnenovMXKU9
1421 Views, 6 Replies

DockablePane hosting chromium browser in WPF page breaks desired functionality

We are developing a simple markdown solution for a client. The attempt is to host the markdown (mkdocs in this case) inside a DockablePane. We are hosting a ChromiumWebBrowser inside a WPF Page which points to the location of the mkdocs website. The solution is really very simple at this stage. 

 

WPF

 

<Page x:Class="RevitAddin1.Pane"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:RevitAddin1"      
             xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             Title="Test Panel">
    <Grid Background="white">
        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <cefSharp:ChromiumWebBrowser Grid.Row="1" 
Address="https://facelessuser.github.io/pymdown-extensions/"/>
        </Grid>            
    </Grid>
</Page>

 

Revit 

 

public Result Execute(UIApplication uIApplication)
        {
            var data = new DockablePaneProviderData();
            var page = new Pane();
                    
            data.EditorInteraction = new EditorInteraction(EditorInteractionType.KeepAlive);
            data.FrameworkElement = page as FrameworkElement;

            var starte = new DockablePaneState
            {
                DockPosition = DockPosition.Right,
            };

            var dpid = new DockablePaneId(new Guid("39FA492A-6F72-465C-83C9-F7662B89F62C"));
            uIApplication.RegisterDockablePane(dpid, "Architype Learn", page as IDockablePaneProvider);

            return Result.Succeeded;
        }

 

For the most part, this runs OK. The problem arises when trying to use the built-in 'Search' functionality of the mkdocs platform. The expectation is to be able to query relevant information within the pages of the documentation. A separate page would show all the hits which the user will be able to navigate to straight from the Search results. When done inside Revit this process will 'break' returning to the current page and hiding the Search bar. 

 

Below is a short video demonstrating the problem. Firstly we show the desired functionality running correctly in WPF App and next to it the exact same setup hosted within a DockablePane inside Revit.

 

 

Any ideas as to why this is happening and how to solve the issue are very welcomed!

Labels (3)
6 REPLIES 6
Message 2 of 7
jeremytammik
in reply to: dnenovMXKU9

Dear Deyan,

 

Thank you for your query.

 

This sounds like a rather tricky problem that has little to do with the Revit API per se and is more related to how Revit interacts with the Windows OS, versus how the ChromiumWebBrowser interacts with the WPF page and the the mkdocs website.

 

I have heard occasional reports about Revit add-ins running into issues when using WPF. Some of them were resolved by juggling a bit with the message routing and such stuff, as far as I can understand. Some such discussions were documented by The Building Coder in the WPF category:

 

https://thebuildingcoder.typepad.com/blog/wpf

 

Other similar issues have been discussed here in the forum; please search here for threads related to WPF.

 

I am sorry I cannot suggest anything more constructive, having no experience whatsoever with any of the three components that you list.

 

I hope this is of some use anyway, and wish you the very best of luck sorting this out.

 

Please do let us know how you end up solving this. Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 7
deyannWXBAT
in reply to: jeremytammik

Hi Jeremy,

 

Thank you for your prompt reply.

 

I agree that the problem is rather tricky to pin, that is why I was hoping to get support from Autodesk Revit API team. As I have documented, the problem does not manifest when WPF is used outside a DockablePane context. I don't know what is happening inside the DockablePane implantation, it's a bit of a black box to me. 

 

I will try testing against Windows  Forms to see if that gets any results. Another test I will perform is hosting inside a modeless Window rather than DockablePane. I will inform you of my findings.

 

Kind regards

Message 4 of 7
jeremytammik
in reply to: deyannWXBAT

Dear Deyan,

 

Thank you for your update and further thought.

 

If I can prove that this issue has anything to do with a problem in Revit, I can certainly ask the development team to take a closer look.

 

Also, obviously, this issue needs to be assessed and prioritised against all other outstanding development requests.

 

So, the more information you can gather by testing the behaviour in other environments, the better.

 

Very often, that kind of narrowing down has actually simplified things enough to reach a solution.

 

Good luck in your testing and hopefully easily resolving the issue.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 7
dnenovMXKU9
in reply to: jeremytammik

Dear Jeremy,

 

I have now tested my case using a WPF modeless form, which has produced the same result. The issue is not isolated to DockablePane.

 

I also tried an alternative to the cefSharp ChromiumWebBrowser, the Microsoft WebViewControl, and interestingly enough reproduced the same issue outside of Revit. 

 

I can only assume that some dependencies are missing - I will keep looking for an answer, but this is not a Revit API issue as you pointed out earlier. Thank you for your response regardless, it is much appreciated!

 

Kind regards,

 

Deyan

Message 6 of 7
dnenovMXKU9
in reply to: dnenovMXKU9

I have finally kinda-sorta figured a solution out. Using WebView2 seem to have fitted the bill in terms of displaying the desired content without breaking any functionality (HTML5 support issues most probably).

 

Using WebView2 on the other hand raised a number of other interoperability issues that required another layer of workarounds. I have posted the current solution as part of this thread https://forums.autodesk.com/t5/revit-api-forum/revit-crashes-when-second-document-is-created-opened-.... If anyone is interested, they could potentially find some insights there.

 

Thank you once again for the support, Jeremy. 

Message 7 of 7
eldho_r
in reply to: jeremytammik

I am having a similar issue with a CEFSHARP-based dock able window that I am trying to create. It works fine with a default address, but when I try to create a WPF event for the CEF browser or assign a name property to it, I am encountering a missing assembly error. My code is similar to @dnenovMXKU9 's code. Do you have any solutions for this problem? 

Thanks in Advance
Eldho_Raju_0-1670883291616.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report