Replies: 1 comment 2 replies
-
Try the XamlRoot.Changed event. It will be fired when the rasterization scale is changed, or when the size is changed. public sealed partial class CustomControl : Control
{
public CustomControl()
{
DefaultStyleKey = typeof(CustomControl);
Loaded += CustomControl_Loaded;
Unloaded += CustomControl_Unloaded;
}
private void CustomControl_Loaded(object sender, RoutedEventArgs e)
{
this.XamlRoot?.Changed += CustomControl_XamlRootChanged;
}
private void CustomControl_Unloaded(object sender, RoutedEventArgs e)
{
this.XamlRoot?.Changed -= CustomControl_XamlRootChanged;
}
private void CustomControl_XamlRootChanged(XamlRoot sender, XamlRootChangedEventArgs args)
{
System.Diagnostics.Debug.WriteLine($"CustomControl XamlRoot changed. [Size: {sender.Size}, Scale: {sender.RasterizationScale}] ");
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing a custom control that performs some drawing using a SpriteVisual and a DrawingSession. It works ok, but when it is inside a ScrollViewer it gets blurred as it is zoomed. How can I get the real rasterization scale, and get notified when it changes?
Beta Was this translation helpful? Give feedback.
All reactions