UWP ScrollViewer.TopHeader with SkiaSharp does not drawing - c#

The I want to use the SkiaSharp Canvas in ScrollViewer, but not only in Main content, but in TopHeader and LeftHeader as well. The paint events are called, the skia is drawing, but the result does not displayed on the screen, just in a main content.
here is the example:
<ScrollViewer
HorizontalScrollBarVisibility="Visible"
HorizontalScrollMode="Enabled"
VerticalScrollBarVisibility="Visible"
VerticalScrollMode="Enabled">
<ScrollViewer.TopHeader>
<Grid
Width="{Binding ElementName=Canvas, Path=ActualWidth}"
Height="30"
Background="LightGray">
<TextBlock Text="Hello" />
<skia:SKXamlCanvas
x:Name="TopHeaderCanvas"
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
PaintSurface="OnPaintTopHeader" />
</Grid>
</ScrollViewer.TopHeader>
<ScrollViewer.LeftHeader>
<skia:SKXamlCanvas
Width="60"
Height="{Binding ElementName=Canvas, Path=ActualHeight}"
Background="Gray"
PaintSurface="OnPaintLeftHeader" />
</ScrollViewer.LeftHeader>
<ScrollViewer.Content>
<skia:SKXamlCanvas
x:Name="Canvas"
Width="4000"
Height="3500"
Margin="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
PaintSurface="OnPaintMainContent" />
</ScrollViewer.Content>
</ScrollViewer>
As You can see, I tried the skia sharp canvas in wrapped in grid, directly under the ScrollViewer. Unfortunately it does not help.
Here is the result.
The left is totally empty, but is should be filled with HotPink, and the TopHeader just displays the Grid with "hello" , but it should be covered by canvas, and filled with Green color.
Anybody has an idea, why the skia is not working in ScrollView TopHeader and Left Header?
The SkiaSharp nuget which contains the canvas:
https://www.nuget.org/packages/SkiaSharp.Views/1.68.2-preview.21
And here are some SkiaSharp example:
https://github.com/mono/SkiaSharp/tree/master/samples/Basic/UWP/SkiaSharpSample

UWP ScrollViewer.TopHeader with SkiaSharp does not drawing
I could reproduce your issue, and I tried to re-draw canvas within PaintSurface but it also does not work, please feel free post this issue in SkiaSharp github, And I will report this to the team.

It was a bug In SkiaSharp.
It is fixed: https://github.com/mono/SkiaSharp/pull/1133
Thank you: mattleibow

Related

Change size of Progress Bar

I have progress bar but dots too small, how I can make it bigger?
I didnt found any property witch can change size of dots. Height/Width change onlly area where dots can move
Xaml code
<Grid // here width ="2560" height="1600"
<ProgressBar
Grid.Row="0"
Grid.Column="1"
IsIndeterminate="True"
Visibility="{Binding MainInstance.Loading, Converter={StaticResource BooleanToVisibilityConverter}}"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"/>
</Grid
There are several options to solve this, it's up to you which one you pick:
Change the default style of ProgressBar and increase the Ellipse Width and Height properties. You can do this in Blend or by copying the style from
C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\10.0.14393.0\Generic\generic.xaml
Use a ViewBox control to wrap around the ProgressBar. This control resizes all content to the available size.
Create a templated control with your own template settings properties.
I have created a small sample on GitHub to show you the code for all possibilities.
Easiest way to change ProgressBar's dots size is to use ScaleTransform:
<ProgressBar ...>
<ProgressBar.RenderTransform>
<ScaleTransform ScaleX="2" ScaleY="2" />
</ProgressBar.RenderTransform>
</ProgressBar>
In my case (WinUI3 SDK1.1.0) I have had a thin 1px-line and it helped me to use the MinHeight property instead of the Height. I hope that MinHeight also will help you with the dotted line.
<StackPanel BorderThickness="0" BorderBrush="LightGray" Padding="12">
<muxc:ProgressBar
Value="{x:Bind Path=XamlProductionViewModel.XamlCurrentProgress, Mode=OneWay}"
IsIndeterminate="{x:Bind Path=XamlProductionViewModel.XamlIsIndeterminate, Mode=OneWay}"
Visibility="{x:Bind Path=XamlProductionViewModel.XamlProgressVisibility, Converter={StaticResource booleanToVisibilityConverter}, Mode=OneWay}"
Foreground="AliceBlue"
Background="Transparent"
Minimum="0"
Maximum="100"
BorderThickness="0"
Margin="0"
MinHeight="25"
Width="300"/>
</StackPanel>
ProgressRing not support any property to change the dots width and height ,and when the ProgressRing have a bigger space the dots will be biggest.
You can use the Grid which get a ProgressBar and the Grid is permanent position.
You use the Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" and you should write the code in Grid.You should give the Grid big space.
ProgressBar should use HorizontalAlignment="Stretch" and the same of VerticalAlignment.You have a big width and big height the dots will have a big width and big height.
<ProgressRing Margin="10,10,10,10"
IsActive="True"
Visibility="{x:Bind View.Visibility,Mode=OneWay}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
I write in the top Grid.You can see my app's ProgressRing have a big dots.
http://jycloud.9uads.com/web/GetObject.aspx?filekey=16bcfec973e910632e04b3990c274a1c

SurfaceInkCanvas scales strokes when painting out of bounds

I have a ScatterView that contains an image over which I should be able to draw.
<s:ScatterView HorizontalAlignment="Center" Margin="0,0,0,0" Name="desk" VerticalAlignment="Center">
<s:ScatterViewItem Width="200" Height="200">
<Grid>
<Image Name="img1" Source="/Resources/Desert.jpg"/>
<Viewbox>
<s:SurfaceInkCanvas Name="cvs1"/>
</Viewbox>
</Grid>
</s:ScatterViewItem>
</s:ScatterView>
I noticed that whenever I draw an ink trail towards the border of the image, the strokes on the ink canvas are scaled down to make room for more stuff. I do not want these strokes to be zoomed out. How can I change this behavior?
Here is a video that shows what's going on.
I figured it out. This behavior is caused by the fact that I hadn't defined a Width and Height on the SurfaceInkCanvas. This should do the trick:
<s:SurfaceInkCanvas Name="cvs1" Width="200" Height="200" />

Drawing over text in metro app

I am creating a drawing metro application for Window 8 using c#. I am Using textblock inside the canvas and Ink-manager for drawing.This work fine but i want to draw a ink only upon the drowntext of textblock not in hole canvas.
Here is code:-
<Canvas Name="canvas"  Background="Transparent" >
<TextBlock  x:Name="txtblock" Margin="80,0,0,0" Foreground="White"
VerticalAlignment="Top" HorizontalAlignment="Center"  FontSize="60"/> </Canvas>
Please help me how to achieve this functionality.
I would think that the most straightforward way is to wrap your TextBlock within another Canvas.
As such, you will have two Canvas, with the child Canvas being positioned within the main Canvas.
One area of concern with this approach would be the sizing of the child Canvas, in which needs to be dynamically resized based on the size of the containing TextBlock.
<Canvas Name="canvas" Background="Transparent" >
<Canvas Name="childCanvas" Background="Transparent">
<TextBlock x:Name="txtblock" Margin="80,0,0,0" Foreground="White" FontSize="60"/>
</Canvas>
</Canvas>

Bring Window Buttons to Front

I'm currently developing a Twitter application for Windows, similar to the Twitter client for OSX.
I'm using the Windows Shell Extensions library found here to make the entire window Aero, and be able to extend beyond the bounds of the designated window location.
I want the window buttons (Minimize, Maximize, Close) to be shown over top of the grid with the white background. This is a functionality that I thought would have been built into Windows, but apparently I'm wrong.
The two images below illustrate my point. In the second image, I want the window buttons to take precedence over the white-background grid, not the other way around like it's shown.
Is there some kind of code snippet or XAML-snippet that'll help me? Has anyone else ever had this problem before?
I stumbled upon a simple, yet dirty solution. I just made a path to go around the outside of the Windows buttons, and set the background of the outside to white, or whatever background color I was using. Then I just pieced rectangles together to make it look nice.
Here's the resulting code:
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Row="0" Height="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.0*" />
<ColumnDefinition Width="105" />
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
<Path HorizontalAlignment="Stretch" Grid.Column="1" Stretch="Fill" VerticalAlignment="Bottom" Height="20" Fill="#FFFFFFFF" Data="M 0,4.11334L 4.008,4.11334C 1.792,4.11334 0,2.27332 0,0L 0,4.11334 Z M 140,4.11334L 135.957,4.11334C 138.192,4.11334 140,4.11334 140,0L 140,4.11334 Z " />
<Border Grid.Column="2" CornerRadius="0, 10, 0, 0" Background="#FFFFFFFF" BorderThickness="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
And here's the resulting image:
you should hide your minimize maximize and close buttons and draw your own like described here.
http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/

GestureListener in ScrollViewer on Windows phone 7 does not work

I have a prblem: If I enter this kind of xaml:
<Grid Grid.Row="1">
<ScrollViewer Name="scrolViewer" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="AliceBlue"
BorderThickness="5" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Image Name="mapImage" CacheMode="BitmapCache" RenderTransformOrigin="0.5 0.5">
<Image.RenderTransform>
<CompositeTransform x:Name="transform" />
</Image.RenderTransform >
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener PinchStarted="OnPinchStarted" PinchDelta="OnPinchDelta" />
</toolkit:GestureService.GestureListener>
Gestures does not work, but image slides as it is expected to.
If I remove tag - gestures begin to work.
How do I enable guestures to zoom and rotate image inside scrollviewer or how do I create my own scrollviewer based on gestures.
Thanx in advance!
I'm not sure putting your image in a ScrollViewer is a great idea as it's possible the gesture handling between ScrollViewer and GestureListener will compete.
See Jeff Prosise's blog for an example of how to zoom/rotate using GestureListener. The whole blog post series is very useful if you want to learn more about WP7 touch.
(Thanks to Derek's answer to a previous SO question.)

Categories

Resources