0
嗨,我試圖改變圖像的透明部分的顏色。請參考圖像 其實我在網格中使用它作爲背景圖像有什麼方法可以改變只有圖像外部的顏色即透明部分,對不透明圖像的主要部分不應施加任何影響。在「FwdBtn」圖像的外部Tap上,主圖像的外部透明部分應該改變。 的XAML試圖改變圖像中的透明部分的顏色
<Grid.Background>
<ImageBrush x:Name="imgbg" ImageSource="Assets/LearnColor/bg.png"
/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition x:Name="rowDefHeaderPanel" Height="1*"/>
<RowDefinition x:Name="rowDefContentPanel" Height="3*"/>
<RowDefinition x:Name="rowDefFooterPanel" Height="1*"/>
</Grid.RowDefinitions>
<RelativePanel x:Name="Headerpanel" Grid.Row="0" Margin="0,0,0,0">
<Image x:Name="prevBtn"
Source="Assets/LearnColor/Button/btn_previous_arrow.png"
RelativePanel.AlignLeftWithPanel="True"
Margin="0,33,-246,23"
Tapped="BckImgChng" HorizontalAlignment="Right" Width="88" d:LayoutOverrides="Height"/>
<Image x:Name="FwdBtn"
Source="Assets/LearnColor/Button/btn_next_arrow.png"
Height="88"
RelativePanel.AlignRightWithPanel="True"
Margin="-152,0,250,-121"
Tapped="FwdImgChng" VerticalAlignment="Bottom" d:LayoutOverrides="HorizontalAlignment"/>
<Image x:Name="Header"
Source="Assets/LearnColor/Header/_0000_header_0.png" Width="440"
RelativePanel.AlignVerticalCenterWithPanel="True"
Margin="0,-39,-814,-62" HorizontalAlignment="Right"
>
<Image.Triggers>
<EventTrigger RoutedEvent="Image.Loaded">
<BeginStoryboard>
<Storyboard x:Name="Blinkopr">
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1" To="0" AutoReverse="True" Duration="0:0:0.9" RepeatBehavior="Forever"
Storyboard.TargetName="Header"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Image.Triggers>
</Image>
<TextBlock x:Name="HeaderName"
Text="Yellow"
FontFamily="Font/BALLOON.TTF#BALLOON"
RelativePanel.AlignVerticalCenterWithPanel="True"
Margin="543,13,-273,7" Foreground="White" FontSize="25" FontStyle="Normal" FontWeight="ExtraBold" />
</RelativePanel>
C#代碼
private void FwdImgChng(object sender, TappedRoutedEventArgs e)
{
//if (currentIndex == 11)
//{ return; }
currentIndex++;
if (currentIndex > 10)
{
currentIndex = 10;
return;
}
Header.Source = new BitmapImage(new Uri("ms-appx:///Assets/LearnColor/Header/_0000_header_" + currentIndex + ".png"));
image.Source = new BitmapImage(new Uri("ms-appx:///Assets/LearnColor/Object/ob_" + currentIndex + "_0.png"));
prevObjBtn.Source = new BitmapImage(new Uri("ms-appx:///Assets/LearnColor/Button/prev" + currentIndex + ".png"));
fwdObjBtn.Source = new BitmapImage(new Uri("ms-appx:///Assets/LearnColor/Button/next" + currentIndex + ".png"));
HeaderName.Text = Headername[currentIndex];
objNameWritten.Text = objnamewritten[currentIndex];
objNameWritten.Foreground = new SolidColorBrush(HColorname[currentIndex]);
mediaElement1.Source = new Uri("ms-appx:///Assets/LearnColor/Objectnamesmp3/C" + currentIndex + ".mp3");
//mediaElement1.AutoPlay = true;
}
嗨,我正在嘗試像這樣的相同圖像ü提到<網格X:名稱= 「Mainbg」> <網格X:名稱= 「2ndgrid」> <圖像刷X:名稱= 「imgbg」 的ImageSource = 「資產/ bg.png」/> <按鈕X:名稱= 「BTN」 的HorizontalAlignment = 「中心」 螺紋= 「btnTap」> C#代碼私人無效btnTap(對象發件人,TappedRoutedEventArgs E) { Mainbg.Background = new SolidColorBrush(Colors.Cyan); Mainbg.Background = new SolidColorBrush(Colors.Cyan); }但給出錯誤的任何分辨率 –
anuj
@anuj錯誤是什麼? – Emad
@Edmad它的工作實際上,我不應該給第二個網格名稱爲「2ndgrid」。當我改變它的名稱時,它的格式不正確。 – anuj