-
Notifications
You must be signed in to change notification settings - Fork 500
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
How a derived class of FrameworkElement creates visual children OR renders #646
Comments
@MikeHillberg @codendone running into this for something I'm trying to work on (CommunityToolkit/WindowsCommunityToolkit#4104). Can you point us in the right direction? It seems in the WinUI repo there's a [ContentProperty(Name = nameof(Child))]
public class ConstrainedPresenter : FrameworkElement Examples from WinUI 2 repo:
It also seems like for (I'm also conflicted on naming it |
@michael-hawker These controls derive from Panel (see |
@codendone then why in the IDL and docs does it show it inheriting from As the
I guess this comment explains it a bit about hiding the implementation detail? Is this possible to achieve in C#? If we want just a single child is there a more direct way? |
@michael-hawker The |
Filed issue microsoft/microsoft-ui-xaml#5530 for tracking exposing this in the Framework for WinUI 3. Sounds like for now I should stick with |
Thanks for documenting
FrameworkElement
. Could you please explain how a derived class ofFrameworkElement
(orUIElement
) can create visual child elements and/or render itself? How to create visual child elements without using a control template? I do realize that the documentation says "Typically, you don't derive classes directly from FrameworkElement", but occasionally it is necessary to derive directly from FrameworkElement, thus it would be greatly appreciated if you could explain how to do this, in particular the rendering or visual children part.I understand that one option is to derive from
Control
instead ofFrameworkElement
and then use a control template, but sometimes templates are not the right solution for a particular UI element class, therefore how can we derive directly from FrameworkElement?For comparison, in the older WPF-Desktop, a derived class could create visual child elements by overriding the following members, but these members do not exist in UWP, therefore how is it done in UWP?
System.Windows.FrameworkElement.VisualChildrenCount
System.Windows.FrameworkElement.GetVisualChild(int)
Also in WPF-Desktop, a class could render itself by overriding
System.Windows.UIElement.OnRender(System.Windows.Media.DrawingContext)
but this method does not exist in UWP, therefore how is it done in UWP?Thank you!
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: