MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

Flipper applies scale when content size changes

Open mycroes opened this issue 7 years ago • 4 comments

I noticed some awkward behavior with the flipper where it seems to scale if the content shrinks (requires less space than before), in my case when a combobox selection is reset. Luckily I happened to have two identical flippers with identical content: flipper scale

It seems like a scale transformation is applied on the Viewport2DVisual3D (this is the right flipper): viewport2dvisual3dright

And here's left for comparison: viewport2dvisual3dleft

I guess the issue might com from the following piece in Plane3D:

private void Update3D()
        {
            // Use GetDescendantBounds for sizing and centering since DesiredSize includes layout whitespace, whereas GetDescendantBounds 
            // is tighter
            var logicalBounds = VisualTreeHelper.GetDescendantBounds(_logicalChild);
            var w = logicalBounds.Width;
            var h = logicalBounds.Height;
            ...
            _scaleTransform.ScaleX = w;
            _scaleTransform.ScaleY = h;

I'm not sure why this doesn't match the actual content size when it shrinks, (or actually, maybe this isn't called when the content shrinks?) but flipping the card back and forth fixes the scale.

I'm sorry for the huge screenshots, they were taken at 200% scale.

mycroes avatar Nov 03 '17 21:11 mycroes

I just noticed this bahavior too. When I have a flipper in a Grid it will shrink when a gridsplitter makes that part of the grid smaller. Also happens when the window size is changed. This makes the Flipper unusable.

I also had the problem of the flipper rendering a little too big when loaded. Meaning the contents of the flipper were rendered larger than the area of the flipper.

<materialDesign:Flipper
    Grid.Row="1"
    Grid.Column="4"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    >

I ended up adding margin to bring it back down to the right size but that is quite annoying. But not as annoying as the incorrect scaling issue which makes the margin problem moot. I tried the card styling too that was way worse.

glen-nicol avatar Apr 11 '18 00:04 glen-nicol

Hi i had a similar Problem with a TextBlock that always rerendered, when i clicked on a CheckBox in the same Grid.

On StackOverflow was a similar Problem: https://stackoverflow.com/questions/6436501/wpf-why-does-text-and-elements-blur-if-i-use-dropshadow-effect-on-a-parent-item

We have a similar case in the Card. The Grid.OpacityMask cause the Content Presenter to render the TextBlock as a Bitmap.

I will setup a merge Request and you can check if that fixes the flipper issue too.

CookiesAndCoffee avatar Apr 18 '18 11:04 CookiesAndCoffee

I just noticed this bahavior too. When I have a flipper in a Grid it will shrink when a gridsplitter makes that part of the grid smaller. Also happens when the window size is changed. This makes the Flipper unusable.

I also had the problem of the flipper rendering a little too big when loaded. Meaning the contents of the flipper were rendered larger than the area of the flipper.

<materialDesign:Flipper
    Grid.Row="1"
    Grid.Column="4"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    >

I ended up adding margin to bring it back down to the right size but that is quite annoying. But not as annoying as the incorrect scaling issue which makes the margin problem moot. I tried the card styling too that was way worse.

This happened to me couple of days ago.. I didn't know about this problem of Flipper, which after two years seems to be there! This is very annoying and disappointing!

valimaties avatar Nov 20 '20 09:11 valimaties

@valimaties Do you still have the problem? If so, please provide us a test repo. It will help us to solve the problem more easily.

ElieTaillard avatar May 28 '22 16:05 ElieTaillard