scrollviewer on image gives black background - xaml

When I set scrollviewer on image with white background and saved it to disc then my saved image has black color background.
<ScrollViewer x:Name="scrollViewer" Height="500" Width="550" VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden" ManipulationMode="All" ManipulationDelta="scrollViewer_ManipulationDelta">
<Image x:Name="targetSecond" Height="200" Width="200" Stretch="Uniform" VerticalAlignment="Top" HorizontalAlignment="Left"
Source="">
<Image.RenderTransform>
<CompositeTransform/>
</Image.RenderTransform>
</Image>
<ScrollViewer.RenderTransform>
<CompositeTransform/>
</ScrollViewer.RenderTransform>
</ScrollViewer>
In scrollviewer I applied dragging of image also, it works fine.
How to save the image with a white background instead of black?

Related

Custom GIF in UWP

I am developing UWP application, to showing loading process i am using a Custom GIF image as usercontrol. I am adding this GIF image user control to a grid like below.
But while running the GIF it hangs some time..But when i use ProgressRing control it is running perfect.
<Grid
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" x:Name="ProcessingGrid"
Visibility="{x:Bind VM.IsProcessing ,Mode=TwoWay,Converter={StaticResource BooleanToVisibilityConverter}}">
</Grid>
This is my Usercontrol
<Grid
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.Background>
<SolidColorBrush Color="Black" Opacity="0.3">
</SolidColorBrush>
</Grid.Background>
<Image x:Name="loadingGif" Source="ms-appx:///Assets/GifAssets/ADProcessingIcon.gif"
Width="80">
</Image>
</Grid>
try using "XamlAnimatedGif" library
<page
....
xmlns:gif="using:XamlAnimatedGif"/>
...
<Image x:Name="imgLoading"
gif:AnimationBehavior.SourceUri="/Assets/GifAssets/ADProcessingIcon.gif"/>
...

How put Image in ScrollViewer WPF

I try bind my Image size to slider, and put it to scroll viewer, but scroll viewer not working. I can't understand why.
<DockPanel Grid.Column="1">
<StackPanel DockPanel.Dock="Bottom" Height="30" HorizontalAlignment="Center" Orientation="Horizontal">
<Button Margin="2,2,2,2" Content="From file" Click="Button_Click"></Button>
<Button Margin="2,2,2,2" Click="delImageClick" ToolTip="Delete">
<Image Source="Resources/empty_trash-48.png"></Image>
</Button>
<Slider x:Name="sldZoom" Orientation="Horizontal" Minimum="1" Maximum="250" HorizontalAlignment="Stretch" MinWidth="100" Value="100"/>
</StackPanel>
<Grid>
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
Image Name="previewImg" Source="{Binding SelectedItem, ElementName=dataGrid , UpdateSourceTrigger=PropertyChanged}" Stretch="Uniform" RenderTransformOrigin="0, 0" >
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.01" ScaleY="0.01"/>
<ScaleTransform>
<ScaleTransform.ScaleX>
<Binding ElementName="sldZoom" Path="Value" Mode="OneWay"/>
</ScaleTransform.ScaleX>
<ScaleTransform.ScaleY>
<Binding ElementName="sldZoom" Path="Value" Mode="OneWay"/>
</ScaleTransform.ScaleY>
</ScaleTransform>
</TransformGroup>
</Image.RenderTransform>
</Image>
</ScrollViewer>
</Grid>
</DockPanel>
Also I try put my Image into Dock and grid,It did not work either
example on this image
I should be using LayoutTransform instead of RenderTransform in my Image.
WPF - Zooming in on an image inside a scroll viewer, and having the scrollbars adjust accordingly

Left and Right Scrolling in Image

i want to display large image in small control such that entire image can be scrolled.
for this, i have used following code but i could only succeed in achieving vertical scrolling.
what should i do for enabling both, horizontal and vertical scrolling ?
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1" Width="470">
<ScrollViewer x:Name="scrollViewer" Width="470" Height="270" HorizontalAlignment="Left" VerticalAlignment="Top">
<Image Name="drag" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Top"/>
</ScrollViewer>
</Grid>
if there is any other solution than using scrollviewer then please share it, or mention any changes in this code which are useful for achieving the same.
Try
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1" Width="470">
<ScrollViewer x:Name="scrollViewer" Width="470" Height="270" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"HorizontalAlignment="Left" VerticalAlignment="Top">
<Image Name="drag" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Top"/>
</ScrollViewer>
</Grid>
You need to set HorizontalScrollBarVisibility and VerticalScrollBarVisibility properties to achieve desired scrolling.
Edit :
If you want to see the scroll bars always you can set HorizontalScrollBarVisibility="Visible" and VerticalScrollBarVisibility="Visible" .Otherwise("Auto") scroll bars will appear based on the content size

RotateTransform applies after Image has been displayed and this causing blinking

I have such DataTemplate:
<DataTemplate x:Name="GreenMarkTemplate">
<Grid Width="64" Height="64">
<Image Source="Assets/Marks/mark_green.png" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<RotateTransform CenterX="0.5" CenterY="0.5" Angle="{Binding course}" />
</Image.RenderTransform>
</Image>
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap" Text="{Binding route_num}" VerticalAlignment="Center" FontSize="16"/>
</Grid>
</DataTemplate>
And I need to rotate Image according to "course" property. At first, Image shows with zero angle and in a moment it rotates. This makes Image blinking.
So, is it possible somehow to make Image invisible and show it only after rotation? or rotate image before rendering it?
Resolved the issue using LayoutTransform port for Windows Phone 8. github link

XAML: WebBrower Background Color?

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox HorizontalAlignment="Left" Name="number" Height="72" TextWrapping="Wrap" VerticalAlignment="Top" Width="240" Margin="24,0,0,0" InputScope="Number" MaxLength="3" />
<Button Content="find" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="269,0,0,0" Width="161" RenderTransformOrigin="0.743,0.541" Name="searchbutton" Click="search"/>
</Grid>
<Grid Grid.Row="1" Margin="0,84,0,0" Grid.RowSpan="2">
<phone:WebBrowser x:Name="browser" IsScriptEnabled="True" Background="Black" Foreground="Black"/>
</Grid>
Here is my xaml code for initializing web browser in my app. But, the web browser appears in white color. I have given all coloring properties as much i know. But it stills in same white color. I need to make it transparent.
Here's my sample image files I captured - http://img829.imageshack.us/img829/6956/rt0n.png
Best answer will be much appreciated.
You can change the background color for webbrowser. Just look at this answer
How to make Webbrowser control with black background in Windows Phone 7.1