microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.28k stars 675 forks source link

Proposal: Make the getter for XamlCompositionBrushBase.CompositionBrush public #3667

Open seanocali opened 3 years ago

seanocali commented 3 years ago

Proposal: [Make the getter for XamlCompositionBrushBase.CompositionBrush public]

Summary

I have custom controls that use CompositionBrushes internally but have XAML Brush dependency properties. I have written XAML Brush to CompositionBrush translations for solid and linear gradient, but not for acrylic or anything else that comes along.

Rationale

I can't think of any dangers to making access to the getter public.

codendone commented 3 years ago

I agree there isn't a strong need to have the getter be protected. Having a public getter might suggest more flexibility than the XamlCompositionBrushBase subclass might support, though. For example:

A public getter could still safely be used to check if the CompositionBrush has been set, or for a test to check if the right type and properties got set, though.

seanocali commented 3 years ago

Good points. Plus if someone disposes the CompositionBrush before the XCBB is done with it I imagine that could be problematic. Maybe there could be a method to clone it? Something like:

Compositor.CreateBrushFromXaml(XamlCompositionBrushBase xamlBrush)

codendone commented 3 years ago

Cloning would solve the Close() issue, but not the "Complex XCBB classes" issue.