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
Related
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
<ContentControl Width="120">
<ContentControl.Content>
<ContentControl>
<ContentControl.ContentTemplate>
<DataTemplate>
<TextBlock Text="ABC" TextAlignment="Right" HorizontalAlignment="Right"/>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</ContentControl.Content>
Please find the above code.
It's not getting right aligned.
It is working, but ContentControl by default aligns it's content to the left with just enough place to show.
You can just set HorizontalContentAlignment to Right in ContentControl, so child don't have to worry about it:
<ContentControl Width="120" HorizontalContentAlignment="Right">
<TextBlock Text="ABC" />
</ContentControl>
Or you can set HorizontalContentAlignment to Stretch and leave the rest for child to figure out:
<ContentControl Width="120" HorizontalContentAlignment="Stretch">
<TextBlock Text="ABC" HorizontalAlignment="Right" />
</ContentControl>
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.
I have a simple Rectangle in XAML
<Rectangle x:Name="rect" IsTapEnabled="True" Height="100" Width="100" Fill="#FF72BB5C" Stroke="#FFFB0000" Tapped="rect_Tapped"/>
It draws fine but when I try and click on it nothing happens.
I have tried making the stroke bigger and clicking that and nothing.
I have tried lots of the other events associated with the Rectangle and nothing fires.
Would there be a problem calling the Tapped event when I'm using a mouse and not a touch screen?
Just faced the same issue. Solved with IsHitTestVisible property for Rectangle and every view above it. True for rect and False for others. Though True is default, could be omitted.
I just found strange and funny solution for this.
If your layout looks like this:
<Grid>
<Canvas>
<Rectangle x:Name="rect" IsTapEnabled="True" Canvas.Top="100" Canvas.Left="100" Height="100" Width="100" Fill="#FF72BB5C" Stroke="#FFFB0000" Tapped="rect_Tapped"/>
</Canvas>
<TextBlock Name="Test" Text="Hi" />
</Grid>
Then change it to this:
<Grid>
<Canvas>
<Rectangle x:Name="rect" IsTapEnabled="True" Canvas.Top="100" Canvas.Left="100" Height="100" Width="100" Fill="#FF72BB5C" Stroke="#FFFB0000" Tapped="rect_Tapped"/>
</Canvas>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Name="Test" Text="Hi" />
</Grid>
I just added VerticalAlignment="Center" HorizontalAlignment="Center" to TextBlock and now it works. Don't know why, but works. I'm going to go deeper into this issue.
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.