Converting String to Color Object in C# WPF
String myColor = "Red";
String xamlString = "<Canvas xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Background=\""+myColor +"\"/>";
Canvas c = (Canvas)System.Windows.Markup.XamlReader.Load(xamlString);
SolidColorBrush mistyRoseBrush = (SolidColorBrush)c.Background;
Color backColor = mistyRoseBrush.Color;
SolidColorBrush FinalBrush = new SolidColorBrush(backColor );
No comments:
Post a Comment