【问题标题】:Coloring a Polygon为多边形着色
【发布时间】:2012-03-20 10:34:13
【问题描述】:

我想给多边形上色...

这是我 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放在字符串前面..

【问题讨论】:

  • 基于以下内容:stackoverflow.com/questions/4305968/…:您可以使用 arrow.Fill = GetColorFromHexa("#FFED1C24");
  • 我不确定我得到的颜色是不是 Hexa Color...这真的行不通..
  • 如果你不确定你得到了一个颜色,那么你为什么要尝试用它来填充多边形呢?
  • 你理解错了:) 我不确定它的格式是否是六进制的。但看起来是:) 我会尝试保罗的回答。不知道是不是你:)

标签: c# windows-phone-7 xaml colors polygon


【解决方案1】:

C#?

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

【讨论】:

  • 这行得通,但就像我说的,我需要使用颜色信息:“0x945316”
  • arrow.Fill = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0x94,0x53,0x16));
  • 当我这样做时,它只会变黑..我采用什么样的值无关紧要......
  • Alpha必须为255,否则会透明
【解决方案2】:

怎么样

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

?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-03
    • 2013-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多