Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

WPF Control Resolution problem with Revit MainWindowHandle

lwlXUTTT
Advocate

WPF Control Resolution problem with Revit MainWindowHandle

lwlXUTTT
Advocate
Advocate

Dear Community,

 

I have a WPF Page Control which switches between Modeless Dialog Window (WPF) and DockablePane in Revit.

  • Modeless Dialog Window - in Zero-Document State
  • DockablePane - at least one Document activated

The problem I have is the COntrol resolution on screen. With DockablePane all WPF Controls in my Page look extremly sharp however once Page is switched to Modeless Dialog Window, WPF Controls get blurry and not sharp.

 

I have assigned Revit MainWindowHangle as the Owner of my Modeless WPF Window:

 

//Method in WpfWindow class
public void AssignOwner(UIApplication UiApp)
{
   IntPtr RevitMainWindowHandle = UiApp.MainWindowHandle;
   WindowInteropHelper helper = new WindowInteropHelper(this);
   helper.Owner = RevitMainWindowHandle;
}

 

 

 

//Window Owner assigned OnApplicationInitialized
private void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e)
{
   myModelessWpfWindow.AssignOwner(UiApp);
}

 

 

Does anyone encounter similar problem or know what could be the Cause / Solution?

 

Any help much appreciated,

Lukasz

0 Likes
Reply
459 Views
4 Replies
Replies (4)

Kennan.Chen
Advocate
Advocate

Can you provide a demo project to reproduce the issue?

0 Likes

ricaun
Advisor
Advisor

What do you mean with 'Controls get blurry'?

 

Is kinda hard to know what's happening without any image or a demo like @Kennan.Chen suggest.

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

RPTHOMAS108
Mentor
Mentor

It may be this is more due to your own personal screen resolution and scaling options you have set in the OS and the differences in GDI+ vs DirectX graphics rather than being Revit API related. It is interesting because Revit perhaps mostly uses GDI+ (I don't know) then it has to show a WPF item in a panel (with WPF generally being rendered via DirectX). Clear though there may be a difference in how the rendering of the panel is done vs the WPF window outside of the Revit UI.

 

There may be support missing for options such as below in one of those technologies, so perhaps the options that are missing make it work where it works and the options that are set don't elsewhere.

 

Additionally sometimes if the app is busy WPF appears to render a static bitmap for the Window which is often blurry (I've noticed that but it is often momentary). Instead of showing you a white rectangle where the unresponsive dialogue should be we'll pretend this image is the Window instead.

 

RPTHOMAS108_0-1686417026563.png

 

0 Likes

Revitalizer
Advisor
Advisor

Hi,

 

there is a SnapsToDevicePixels property for UIElement class which is inherited to child controls.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes