【发布时间】:2014-10-01 14:57:16
【问题描述】:
我正在开发一个应用程序,它需要从图库中选择背景图片。为此,我正在实现与Windows phone 8.1 中的Choose Photo 功能相同的功能(设置背景图像),
我试过这个:
xaml:
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Name="contentPanel">
<ScrollViewer Name="scrl" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Opacity="0.3">
</ScrollViewer>
<ScrollViewer Name="scrlView" Height="500" Width="300" BorderBrush="Red" BorderThickness="1" Background="Transparent">
</ScrollViewer>
<Image Name="mtpImg" Stretch="Fill" />
</Grid>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar Mode="Minimized">
<shell:ApplicationBarIconButton IconUri="Assets\ApplicationIcon.png" Click="gallery_click" Text="gallery"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
C#:
private void gallery_click(object sender, EventArgs e)
{
PhotoChooserTask chooser = new PhotoChooserTask();
chooser.Completed += gallery_Completed;
chooser.Show();
}
private void gallery_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK)
{
Image img = new Image();
BitmapImage tmpBitmap = new BitmapImage();
tmpBitmap.SetSource(e.ChosenPhoto);
img.Source = tmpBitmap;
scrl.Content = img;
}
}
问题:如何设置opacity=1 以在scrlView ScrollViewer 中显示图像?
【问题讨论】:
标签: c# xaml windows-phone-8 windows-phone-8.1 scrollviewer