我有一些黑白的透明图像。我想用颜色选择器改变这些透明图像的颜色。我怎么能这样做。
<Image x:Name="img" HorizontalAlignment="Left" Stretch="Fill" Width="50" Height="50" Margin="148,263,0,375" >
</Image>
<c4fToolkit:ColorPicker x:Name="picker" Height="200"
Width="200" ColorChanged="picker_ColorChanged" Margin="270,283,10,245" Opacity="0.5" />
.cs代码是
private void picker_ColorChanged(object sender, System.Windows.Media.Color color)
{
tattoo.Source = new SolidColorBrush(color);
}
答案 0 :(得分:0)
您可以将图像封装在堆叠面板或网格中并设置其背景
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Background="Aqua" Height="100" Width="100" Grid.Row="0">
<Image Name="img" Source="Assets/StoreLogo.scale-240.png" Height="100" Width="100"/>
</StackPanel>
</Grid>