0
我的XAML代碼看起來像這樣想通過C#來上傳圖片在橢圓的背景
<StackPanel Orientation="Vertical">
<Ellipse x:Name="dp" Height="250" Width="250" Margin="0,10,0,0">
<Ellipse.Fill>
<ImageBrush ImageSource="Assets/img.jpg"/>
</Ellipse.Fill>
</Ellipse>
<Button Content="Upload Image" Margin="236,0,0,0" Click="Button_Click"/>
</StackPanel>
&想通過點擊按鈕來更改背景圖片(「上傳圖片」) &這是我的後端編碼在C#
FileOpenPicker fop = new FileOpenPicker();
fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
fop.FileTypeFilter.Add(".jpg");
fop.FileTypeFilter.Add(".jpeg");
StorageFile file = await fop.PickSingleFileAsync();
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.Read);
if (file!=null)
{
BitmapImage bmp = new BitmapImage(new Uri(stream.));
ImageBrush brush = new ImageBrush();
brush.ImageSource = bmp;
}
我Begineer在窗口應用程序
是的,它的作品我都只需添加「BMP .SetSource(流);」這條線在上述條件...謝謝你這麼多 –