2012-03-20 72 views
0

我要顏色的多邊形...着色多邊形

這是多邊形我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> 

而這正是我從得到的顏色:

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

lbi.Color => "0xED1C24" 

現在我要填補這個多邊形與此顏色...

我試圖做到這一點與

arrow.fill('blue'); 

(只是隨機顏色嘗試,如果它是可行的。),但它沒有工作...

有人可以幫我嗎?

編輯:

好吧,它現在的作品。

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

的問題是,我不知道,我已經把#FF在前面的字符串..

+1

基於以下幾點:http://stackoverflow.com/questions/4305968/windows-phone-7-dynamically-set-button-background-color-from-hex:你可以使用arrow.Fill = GetColorFromHexa( 「#FFED1C24」); – 2012-03-20 10:52:32

+0

我不知道如果我得到的顏色是六角顏色...這並沒有真正的工作.. – MrTouch 2012-03-20 11:24:17

+0

如果你不確定你是否得到一個顏色,那麼你爲什麼試圖用它填充多邊形? – 2012-03-20 11:27:49

回答

2

C#?

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

這個工程,但就像我說的,我需要做的顏色信息:「0x945316」 – MrTouch 2012-03-20 11:22:40

+0

arrow.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0x94,0x53, 0x16)); – paul 2012-03-20 11:29:09

+0

當我這樣做時,它只是變成黑色..不重要我採取什麼樣的價值... – MrTouch 2012-03-20 13:13:17

2

什麼

arrow.Fill = new SolidColorBrush(Colors.Blue);