How to create scrollable canvas in WinRT? - windows-8

I tried this, but I can't scroll the canvas. I tried to handle mousewheel change event of other controls but scrolling is not working. Anybody has idea what I am doing wrong ?
<Viewbox Stretch="Fill" StretchDirection="Both" Height="300" Width="300">
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled" Margin="20,0,20,0" Height="300" Width="300">
<Canvas Background="White" Height="300" Width="500">
<TextBlock FontSize="20" Text="This Is Far Right" Canvas.Left="350" Foreground="Black" />
</Canvas>
</ScrollViewer>
</Viewbox>

Try specify width and height of the canvas bigger than the outer element, eg.
<Canvas Background="White" Width="500" Height="500" />

ScrollViewer.VerticalScrollMode="Disabled" solved my problem.

Related

WPF- Auto Resize the popup control

I am New WPF. I have PopupControl below is XAML for that:-
<Popup Name="PopupRemark" AllowsTransparency="True" Placement="Left" HorizontalOffset="45" VerticalOffset="-22"
PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ToggleButton}}"
IsOpen="{Binding IsChecked, ElementName=btnInfo}" StaysOpen="False" >
<Canvas Width="230" Height="200" Background="Transparent" >
<Path x:Name="Container" Canvas.Left="0" Canvas.Top="0" Fill="#f2f6f7" Stroke="#A9A9A9"
Data="M 230,40 L220,50 220,90 0,90 0,0 220,0 220,30 230,40">
<Path.Effect>
<DropShadowEffect BlurRadius="18" Color="Black" Opacity="0.4"/>
</Path.Effect>
</Path>
<Label Grid.Row="0" FontSize="13" FontWeight="Bold" FontFamily="Roboto" Content="Remark" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center"/>
<TextBlock Canvas.Left="5" Canvas.Top="25" Width="210" Text="{Binding Remark}" Foreground="#2c3e50" FontFamily="Roboto" FontSize="11" TextWrapping="Wrapwithoverflow" />
</Canvas>
</Popup>
Issue is, I want to set auto height & width for canvas or popup control so my popup will size as per content into it.I googled and knew that canvas should have fix height or width but is there any solution(Workaround) to make popup auto sizable.or how can add scroller into popup. It will be greatly appreciable
Thanks in advance

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

Adding Contacts.contactdown to TagVisualization

I am working with TagVisualization, which displays an ellipse around the tag with name. I want to put 2 round buttons on the circumference (at well defined points) on the ellipse so that clicking them will result in change of some label text. I am unable to do this because I am unable to add s:Contacts.ContactDown property to the smaller ellipse.
Below is the XAML:
<s:TagVisualization x:Class="ControlsBox.TagVisual"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
Loaded="TagVisual_Loaded">
<Canvas>
<Ellipse Width="300" Height="300" Stroke="White" StrokeThickness="8" Opacity="0.7">
<Ellipse.Effect>
<BlurEffect Radius="12" />
</Ellipse.Effect>
</Ellipse>
<Ellipse Height="296" Width="296" Stroke="AntiqueWhite" StrokeThickness="4" >
<Ellipse.Effect>
<BlurEffect Radius="4"/>
</Ellipse.Effect>
</Ellipse>
<Label Content="John's Phone" HorizontalContentAlignment="Center" Padding="0,250,0,0" VerticalContentAlignment="Bottom" IsHitTestVisible="false">
<Label.Effect>
<DropShadowEffect BlurRadius="9" ShadowDepth="0" Color="Aqua"/>
</Label.Effect>
</Label>
<Ellipse Height="40" Width="40" Stroke="White" StrokeThickness="4" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,70,0,0" Fill="Black"
s:Contacts.ContactDown="UNABLE_TO_ADD" />
</Canvas>
After doing bit of googling, it appeared that using Expression Blend to create buttons with a style is an easier option.

Silverlight ScrollViewer

I have a ContentControl wrapped in a ScrollViewer but for some reason I cant work out even though the content that I place within the ContentControl is bigger than the visible space the scrollbars do not get enabled. The verticalscrollbarvisibilty is set to visible.
When I view my silverlight app the vertical scrollbar is also cut off at the bottom i.e. I cant see the button that you would use for scrolling ownwards.
Can anyone shed any light on this or point me in the right direction.
there is no reason for that may be you are doing something wrong see this code may be this will help you
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="200" Height="200">
<Grid Width="500" Height="400">
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="Hello"/>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Right" Text="World"/>
</Grid>
</ScrollViewer>
sorry forgot to add the layout grid
<Grid x:Name="LayoutRoot" Background="White">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="200" Height="200">
<Grid Width="500" Height="400">
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="Hello"/>
<TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Right" Text="World"/>
</Grid>
</ScrollViewer>
</Grid>

Hiding the scrollbar for a listbox in Silverlight

Please let me know how i can hide the scrollbar from being displayed in Silverlight.
I dont want vertical or horizontal scrollbar. i want to hide both . PLease help
You can set the ScrollViewer.HorizontalScrollBarVisibility and/or ScrollViewer.VerticalScrollBarVisibility attached properties to "Disabled". For example, if you have the following XAML:
<ListBox Height="100" Name="listBox1" Width="100">
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FF894220" />
</ListBoxItem>
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FFB94222" />
</ListBoxItem>
</ListBox>
You will therefore get scrollbars, like so:
[Unfortunately StackOverflow won't let me post the images until I get a higher reputation (which I'm trying to build). You'll have to imagine it or try it yourself]
Adding the ScrollViewer attached properties to the ListBox element:
<ListBox Height="100" Name="listBox1" Width="100"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FF894220" />
</ListBoxItem>
<ListBoxItem>
<Rectangle Width="200" Height="50" Fill="#FFB94222" />
</ListBoxItem>
</ListBox>
results in no scrollbars.
Hope this helps...
Chris