Answer the question
In order to leave comments, you need to log in
How to open and scale a BitmapImage?
Hello,
I just started programming, I ask for help, I can’t figure out how to scale an image with two fingers, just like when opening an image in albums?
More details available code
<ListView Grid.Row="0" Margin="19,0,0,0" x:Name="MyPanel" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick">
<TextBlock x:Uid="Header" Text="My" Style="{ThemeResource TitleTextBlockStyle}" Margin="0,12,0,0"/>
<TextBlock Text="{Binding Title}" Style="{ThemeResource BaseTextBlockStyle}" Margin="0,10,0,0" CharacterSpacing="{ThemeResource PivotHeaderItemCharacterSpacing}" />
<TextBlock x:Name="mtext" Style="{ThemeResource BaseTextBlockStyle}"/>
</ListView>
private void PanelAddImage(string img) {
count++;
string G = "img" + count.ToString();
BitmapImage I = new BitmapImage(new Uri(img, UriKind.Absolute));
MyPanel.Items.Add(new Image { Name = G, Source = I});
}
Answer the question
In order to leave comments, you need to log in
BitmapImage has DecodePixelWidth, DecodePixelHeight size to convert.
var uri = value as string;
if (string.IsNullOrWhiteSpace(uri))
return null;
var image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri(uri);
if (Width != null)
image.DecodePixelWidth = (int)Width;
if (Height != null)
image.DecodePixelHeight = (int)Height;
image.EndInit();
return image;
var uri = value as string;
if (string.IsNullOrWhiteSpace(uri))
return null;
var source = new BitmapImage(new Uri(uri));
var image = new Image { Source = source };
if (Width != null)
image.Width = (int)Width;
if (Height != null)
image.Height = (int)Height;
return image;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question