无法从'System.Windows.Media.Brush'转换为'System.Windows.Media.Color

时间:2018-02-04 12:09:37

标签: c# wpf

我正在尝试让颜色选择器在我的组合框内工作iv设法让它列出颜色,但我遇到一些问题,让它从Media.Brush转换为Media.Color

private void BrushColorCombo_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    Color DrawColor = (Color)(BrushColorCombo.SelectedItem as PropertyInfo).GetValue(null, null);
}
startPoint = e.GetPosition(PaintCanvas);

rect = new Rectangle
{
    Stroke = Drawcolor,
    StrokeThickness = 1
};

rect.Fill = new SolidColorBrush(Drawcolor);
Canvas.SetLeft(rect, startPoint.X);
Canvas.SetTop(rect, startPoint.Y);
PaintCanvas.Children.Add(rect);
return;

0 个答案:

没有答案