user3159792
user3159792

Reputation: 374

How to get the color hex value of a UI control in UWP

Lets say i have this rectangle with the name Rect

<Rectangle Name="Rect" Grid.ColumnSpan="2"  Fill="#FF0099BB"/>

How can i get the Fill value of it, in code? I tried return Rect.Fill.ToString() but all i got was the namespace and class and object of that control.

Upvotes: 1

Views: 145

Answers (1)

M. Wiśnicki
M. Wiśnicki

Reputation: 6203

Try cast it to a SolidColorBrush;

 var someBrash = Rect.Fill as SolidColorBrush;
    if(someBrash != null)
        someColor = brush.Color

Upvotes: 1

Related Questions