You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces a rather brute-force "solution" to issue #796.
A new method Refresh is added to the GradientSlider which allows the developer to inform the control that the GradientStopCollection has been modified externally.
@Avid29 if you make this an ObservableCollection does that change anything? That's the crux of the problem. I don't remember if that always will work with how the XAML compiler initializes the collections in all scenarios though. Especially if the dev does a GradientStopCollection in code-behind and assigns it later.
@michael-hawker I'm not sure I understand what you mean. That code is using collection initialization syntax to initialize a GradientStopCollection, which is its own concrete type and the type for the main input/output property of the control. It cannot be simply replaced with an ObservableCollection.
However, whether or not using Microsoft.UI.Xaml.Media.GradientStopCollection for the main data property is right to use at all is a valuable discussion. Here's a pros and cons list off the top of my head:
Pros
Cons
Is a pre-existing type
Does not have a collection updated event
Can bind the control to other GradientBrushes in the Visual Tree
Uses Microsoft.UI.** type for data (which is weird to put in the ViewModel for MVVM)
Using a Microsoft.UI.** type for data bothers me particularly. I like to fully separate my View, ViewModel, and Model into separate projects where only the View has any UI package references. Currently there's no solution which makes that feasible.
I think my perspective is to leave as is (with this change) for now, and look at something using a System.Numerics.** color when we get to .NET 11.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a rather brute-force "solution" to issue #796.
A new method
Refreshis added to theGradientSliderwhich allows the developer to inform the control that theGradientStopCollectionhas been modified externally.