I'm trying to bind a button click command to a function in C# for WinUI3 to change the color of a line element.
I get the following error message:
CS0029: Cannot implicitely convert 'Windows.UI.Color' to 'System Drawing Color'
I copied the code from Microsoft's Learn website. The first issue I had was with the cp.Color property.
Here's what I have so far:
I've tried the following:
I get the following error message:
CS0029: Cannot implicitely convert 'Windows.UI.Color' to 'System Drawing Color'
I copied the code from Microsoft's Learn website. The first issue I had was with the cp.Color property.
Here's what I have so far:
Code:
Xaml code:
<Grid Width="110" Height="68" Canvas.Top="200" Canvas.Left="200" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">
<ColorPicker ColorChanged="cpe" IsAlphaEnabled="False" IsColorPreviewVisible="True" IsColorSliderVisible="True" IsHexInputVisible="True" IsMoreButtonVisible="True"></ColorPicker>
<Button x:Name="confirm" Content="Confirm" Click="confirmColor_Click"></Button>
<Button x:Name="cancel" Content="Cancel" Click="cancelColor_Click"></Button>
</Grid>
C# code:
private void confirmColor_Click(object sender, RoutedEventArgs e)
{
ColorPicker cp = new ColorPicker();
Color clr = cp.Color;
btn.Flyout.Hide();
ln1.Stroke = clr;
}
I've tried the following:
Code:
private void confirmColor_Click(object sender, RoutedEventArgs e)
{
ColorPicker cp = new ColorPicker();
Color clr = cp.Color;
Brush brsh = clr;
btn.Flyout.Hide();
ln1.Stroke = brsh;
}