Search code examples
c#windows-phone-7xamlcolorspolygon

Coloring a Polygon


I want to Color a Polygon...

This is the Polygon in my Compass.xaml:

<Polygon x:Name="arrow"  Points="5, 90 35, 90 35, 160 65, 160 65, 90 95, 90 50, 5" Stroke="Black" StrokeThickness="4" Fill="White" Margin="42,32,184,0" Grid.Column="1" Grid.ColumnSpan="2" Height="163" VerticalAlignment="Top">
    <Polygon.RenderTransform>
        <RotateTransform x:Name="rotateArrow" Angle="0"  CenterX="50" CenterY="160" />
    </Polygon.RenderTransform>
</Polygon>

And this is where I get the Color from:

Channel lbi = (Channel) GlobalVariables.ChannelList[Channelindex];

lbi.Color => "0xED1C24"

Now i have to fill this Polygon with this Color...

I tried to do it with

arrow.fill('blue'); 

(Just random color to try out if it would work.) but it didn't work...

Can somebody help me out?

EDIT:

Ok it works now.

string[] colorsplit = currentChannel.Color.Split('x');
arrow.Fill = GetColorFromHexa("#FF"+colorsplit[1]);

the Problem was that I didn't knew that i have to put #FF in front of the string..


Solution

  • C#?

    arrow.Fill = new SolidColorBrush(System.Windows.Media.Colors.Blue);