Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual of a UIElement is not sized? #10

Closed
JustinXinLiu opened this issue Dec 17, 2015 · 4 comments
Closed

Visual of a UIElement is not sized? #10

JustinXinLiu opened this issue Dec 17, 2015 · 4 comments

Comments

@JustinXinLiu
Copy link

What I've noticed is the following piece of code will always return a Size of (0,0) for any UIElement.

var visual = ElementCompositionPreview.GetElementVisual(MyUIElement);
Debug.WriteLine($"Visual's size: {visual.Size}");

Output

Visual's size: <0, 0>

Is this by design? I wonder what if I want to animate the Size of the element using Composition Animations?

@sernaj
Copy link
Contributor

sernaj commented Jan 5, 2016

The preview API ElementCompositionPreview.GetElementVisual() currently returns a Visual with a size of 0,0 by design. Our recommendation is to use transforms instead of size animations where possible since transforms can be independently animated to provide a smooth visual experience. As with XAML Storyboards, the size of XAML elements can’t be animated independently because it’s dependent on XAML layout and potentially app code running on the UI thread. We are looking at options in the future to expand interop between XAML and composition APIs in this area.

@JustinXinLiu
Copy link
Author

Thanks @sernaj . Just want to clarify, the transforms you mentioned are Visual properties like Rotation, Scale, Offset, etc. Right?

@sernaj
Copy link
Contributor

sernaj commented Jan 26, 2016

Correct.

@JustinXinLiu
Copy link
Author

Thanks for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants