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

UIElement Translation and other Vector3 Properties are not DependencyProperties #2130

Closed
michael-hawker opened this issue Mar 19, 2020 · 7 comments
Labels
needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) no-issue-activity team-Rendering Issue for the Rendering team wct

Comments

@michael-hawker
Copy link
Collaborator

Describe the bug
Because these particular UIElement properties are not DependecyProperties they cannot be set in Styles which makes it difficult to configure multiple elements with the same style of course...

Steps to reproduce the bug

<ListView HorizontalAlignment="Center" VerticalAlignment="Center"
                  ItemsSource="{x:Bind Items}">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Shadow" Value="{StaticResource BackgroundGridShadow}"/>
                    <Setter Property="Translation" Value="0,0,64"/> <!-- Error Here -->
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="x:String">
                    <Border BorderBrush="Black" CornerRadius="8">
                        <TextBlock Padding="16" Text="{x:Bind}" FontWeight="SemiBold" Foreground="Black"/>
                    </Border>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

Expected behavior
Able to add value to Translation in Style.

Version Info

Windows 10 version Saw the problem?
Insider Build (19584) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop
Mobile
Xbox
Surface Hub
IoT

Additional context
Related Issue #938

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Mar 19, 2020
@michael-hawker
Copy link
Collaborator Author

Part of this may stem from an more complex issue that you can't make an Attached Property that's of a struct type???

@StephenLPeters
Copy link
Contributor

@codendone I think this is by design right? the translation property is a facade and I think they a purposely not DPs

@StephenLPeters StephenLPeters added the team-Rendering Issue for the Rendering team label Mar 20, 2020
@michael-hawker
Copy link
Collaborator Author

Even if it's a facade, there could still be a DP for the facade so that it could be styled.

@codendone
Copy link
Contributor

These are indeed intentionally not DPs, but that requires a bit more explanation.

For several years we've been searching for ways to improve the performance of XAML. One of the places where lots of time is spent is handling of DPs. DPs are powerful, which can be great, but they also can be quite expensive due to their ability to have default values, values set by style, local values, and animated values. These options incur both memory and CPU overhead. And even properties which only get set locally pay significant cost just to set and read that local value. To reduce the cost of properties, we've been working on a new "simple property" model.

The UIElement.Translation/Scale/Rotation (and others) are amongst the first simple properties. These are far more efficient -- if I recall correctly, I believe it was at least a 10x improvement for CPU.

As you point out, we do currently have the problem that they can't be set via style. This is something we intend to fix, though we haven't yet decided on how to do that. It is possible that we may create a new type of Setter which supports simple properties. Whatever the form, this won't be until after WinUI 3.0.

I expect we'll eventually have a separate feature logged to "add style support for simple properties", but for now we can use this issue to track that.

@codendone codendone added needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) and removed needs-triage Issue needs to be triaged by the area owners labels Mar 24, 2020
@michael-hawker
Copy link
Collaborator Author

Thanks @codendone for the info and details on this!

I know there's a lot of opportunities to evolve and move things forward for XAML to improve performance, but it does make it hard for our developers if there's no stop-gap or guidance available for what they're used to doing with the platform (markup, styling, animations, etc...) and how to enable those scenarios with these new properties. Is there an easy way to identify these new types of properties in the docs (or would it just be the ones that don't have DepedencyProperty backings)?

I worked around this limitation by writing an attached property to do the 'listening' and styling aspects and just pass the value to the framework for the given property. This of course adds back the extra overhead, but at least enables this scenario for now. Maybe in the future, more could happen at compile-time for these scenarios like how x:Bind has improved performance?

In the meantime, I could add them to the Toolkit for now at least until this issue is resolved for those that don't need the high-performance throughput, but need to style a few components?

@codendone
Copy link
Contributor

There isn't a clear way to identify which properties are the new "simple properties". Not having a matching DependencyProperty is a potential indicator, but there have been a few other properties we've added in the last few years where we haven't added a DependencyProperty when we believed that support was not needed for those specific properties. Currently this is the set of properties using the new "simple property" implementation:

  • UIElement.CenterPoint
  • UIElement.Rotation
  • UIElement.RotationAxis
  • UIElement.Scale
  • UIElement.TransformMatrix
  • UIElement.Translation
  • BrushTransition.Duration
  • ScalarTransition.Duration
  • Vector3Transition.Components
  • Vector3Transition.Duration

mntone added a commit to mntone/AngelUmbrella that referenced this issue Jan 12, 2023
DO NOT PUBLIC API. I don't know to be unable to bind to the property `UIElement.Translation`.
ref. microsoft/microsoft-ui-xaml#2130
mntone added a commit to mntone/AngelUmbrella that referenced this issue Jan 12, 2023
DO NOT PUBLIC API. I don't know to be unable to bind to the property `UIElement.Translation`.
ref. microsoft/microsoft-ui-xaml#2130
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-winui-3 Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3) no-issue-activity team-Rendering Issue for the Rendering team wct
Projects
None yet
Development

No branches or pull requests

4 participants