I cannot assign GradientStopCollection created in xaml to LinearGradientBrush.GradientStops - by Sachin S

Status : 


Sign in
to vote
ID 778892 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 2/9/2013 3:07:23 PM
Access Restriction Public


Ideally I should be able to create a GradientStopCollection in my xaml and should be use it anywhere by assigning it to LinearGradientBrush.GradientStops but simple assignment like this -
<GradientStopCollection x:Name="Stops">
            <GradientStop Color="White" Offset="0.0"/>
            <GradientStop Color="#f2f2f2" Offset="0.5"/>
            <GradientStop Color="#eaeaea" Offset="0.75"/>
            <GradientStop Color="#d6d6d6" Offset="1.0"/>

LinearGradientBrush brush = new LinearGradientBrush();
brush.GradientStops = Stops; <Wont work>

will not work. 

Also something like this also throw exceptions
LinearGradientBrush brush = new LinearGradientBrush();
brush.GradientStops = new GradientStopCollection();
GradientStop stopFromXaml = Stops[0];
brush.GradientStops.Add(stopFromXaml); <- this line cause exception 

However something like will work. Not sure why it is needed to create new object to 
add to existing GradientStopCollection.

foreach (GradientStop xamlStop in Stops)
                    GradientStop stop = new GradientStop();
                    stop.Color = xamlStop.Color;
                    stop.Offset = xamlStop.Offset;
Sign in to post a comment.
Posted by Microsoft on 3/4/2013 at 2:59 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.
–WPF Team.
Posted by Microsoft on 2/10/2013 at 10:01 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 2/9/2013 at 3:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)