Disable diagonal panning in nested FlipView - xaml

My XAML roughly looks as follows.
<FlipView>
<FlipViewItem>
<Grid Height="400" Background="Blue"/>
</FlipViewItem>
<FlipViewItem>
<Grid>
<FlipView x:Name="DigestFlipView" Style="{StaticResource DigestViewStyle}"/>
</Grid>
</FlipViewItem>
</FlipView>
And then in my DigestViewStype I have made it vertical as follows:
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
What I want is, when swipe is vertical, only inner FlipView should kick in. Also, when swipe is horizontal, only outer FlipView should kick in.
I get the desired behavior if I replace inner FlipView with a ListView. ListView scrolls for vertical swipes and FlipView for horizontal ones. I have tried playing with templates with no luck. Is there a way to achieve what I need with FlipViews?

A ScrollViewer can scroll horizontally. A ScrollViewer can scroll vertically. And, a ScrollViewer can scroll both horizontally and vertically - you are calling this third case "diagonal" scrolling.
A ScrollViewer has a feature where once it starts scrolling either horizontally or vertically, it will no longer scroll the opposite. It sounds like this is what you want. This feature is called "rails".
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.ishorizontalrailenabled.aspx
https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.isverticalrailenabled.aspx

Related

The ScrollViewer automatically changes its height and does not scroll

In my program, I use ScrollViewer to display elements inside, but the problem is that when the ScrollViewer is filled with content, its height automatically changes and it becomes impossible to scroll since the height is equivalent to the content. I put a ScrollViewer inside a Grid and it automatically stretches to its full height VerticalAlignment="Stretch". I can't pre-limit its height because its height automatically adjusts to its parent to fill all the space. How can I solve this?
<Grid Grid.Column="0" RowSpacing="10">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="35"/>
<RowDefinition MaxHeight="35"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="2">
<ScrollViewer VerticalAlignment="Stretch" VerticalScrollMode="Enabled" VerticalScrollBarVisibility="Visible" HorizontalScrollMode="Disabled">
<ItemsControl x:Name="notesContent" Loaded="NotesContent_Loaded" Margin="0,0,15,0">
<ItemsControl.ItemContainerTransitions>
<TransitionCollection>
<AddDeleteThemeTransition>
</AddDeleteThemeTransition>
</TransitionCollection>
</ItemsControl.ItemContainerTransitions>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</Grid>
</Grid>
The ScrollViewer automatically changes its height and does not scroll
The ScrollViewer parent is Grid, and you have set it's VerticalAlignment proeprty as Stretch, it will vertically fill into grid. And it is by design, you can refer to Grid document.
And if you want to make ScrollViewer scrollable, you need to make the content large than ScrollViewer actual height, and the better way is specific height value for ScrollViewer.

UWP PersonPicture control background not being set

PersonPicture is a control offered in Microsoft's Universal Windows Platform.
It looks great, which is why I'm trying to use it to display a user's initials with a background color.
The problem is that when I set the control's background to a color, the background is not changed on the display.
<PersonPicture Initials="JF"
Background="Red"/>
In the above code, the Background still remains the default, while everything else is updated.
Please if you have been able to set the background color, share how you've done it!
I found the template for the PersonPicture through this question: How to get all Controls' ControlTemplates Programmatically?(UWP)
The PersonPicture ignores its Background property and uses a couple of brushes that make up the colors of the control depending on Dark/Light theme and some hard coded values.
It draws an ellipse/circle and thus shows its container's color in the four corners.
Assuming you want to set the color in the square that contains the picture you could do this:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<PersonPicture />
</Grid>
</Grid>
The first grid represents a page. The second grid tightly wraps around the PersonPicture:
Note how the personpicture is somewhat transparent and shows the color of the grid. The color that the template uses for the ellipse is #77FFFFFF
So you could take it a step further by adding an ellipse:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<Ellipse Fill="White"/>
<PersonPicture />
</Grid>
</Grid>
This allows you to control the color of the picture somewhat by setting the color of the ellipse:
Do note that it still mixes the PersonPicture with the background so you cannot set it to black:
<Grid Background="Green">
<Grid HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Red">
<Ellipse Fill="Black" />
<PersonPicture />
</Grid>
</Grid>
Shows:
And finally, you could copy the template (see: How to get all Controls' ControlTemplates Programmatically?(UWP))
and adjust it to use the Background property.

XAML: Semantic Zoom - Vertical Scroll doesn't work

I need a vertical scroll in both - ZoomInView and ZoomOutView, but it doesn't work. I have tried to specify a horizontal scroll and it works fine, but I need vertical orientation - does anyone has any ideas? Here is my code:
<SemanticZoom x:Name="semanticZoom" ScrollViewer.ZoomMode="Enabled"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollMode="Enabled"
Margin="5,48,5,60">
<SemanticZoom.ZoomedOutView>
<ListView ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.IsVerticalScrollChainingEnabled="False">
...
</ListView>
</SemanticZoom.ZoomedOutView>
<SemanticZoom.ZoomedInView>
<GridView ItemsSource="{Binding Source={StaticResource Collection}}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollMode="Enabled"
ScrollViewer.IsVerticalScrollChainingEnabled="False">
...
The height of control inside of the ScrollViewer should larger than the height of the ScrollViewer. If not, the ScrollViewer can not be scrolled. If we do not set the Height of the ListView, the ActualHeight of the ScrollViewer is same to the Height of content. The ScrollableHeight is 0.
You should be able to set a value to the Height property of the SemanticZoom or the ListView.

RenderTransform occurs after EntranceThemeTransition on a TextBlock

I'm applying an EntranceThemeTransition animation to a TextBlock. The TextBlock has a style of PageHeaderTextStyle which has a RenderTransform in it. The issue I'm having is that the RenderTransform applies a Translation effect that doesn't actually render until after the animation is done playing. So, it looks weird because the animation scrolls the control in, and then suddenly the translation snaps the text in place. Does anyone know why this happens?
Is there a way to play the animation with the translation taken into account?
Transform:
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform X="-2" Y="8"/>
</Setter.Value>
</Setter>
TextBlock:
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="{Binding Title}" Style="{StaticResource PageHeaderTextStyle}">
<TextBlock.Transitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</TextBlock.Transitions>
</TextBlock>
I just came up against exactly the same issue. The way to solve it is to nest the TextBlock one level away from the Grid with the transition on it, for example with a second Grid.
What happens is the transition applies a transform to each of its children, but any transform they may have had is replaced temporarily until after the animation completes, resulting in the nasty 'snap' when the original transform is applied afterwards.
In the following example, the transition will run, replacing the TextBlock's transform, and then after the transition ends the original transform will be applied. You see the 'snap':
<Grid Style="{StaticResource LayoutRootStyle}">
<TextBlock Text="Header" Style="{StaticResource PageHeaderTextStyle}"
Margin="0,0,0,40"/>
</Grid>
In the next example, the transition runs and the transform is applied to the Grid, leaving the TextBlock's transform unaffected. No 'snap':
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid>
<TextBlock Text="Header" Style="{StaticResource PageHeaderTextStyle}"
Margin="0,0,0,40"/>
</Grid>
</Grid>
Hope this helps!
From your words it just seems like the EntranceThemeTransition animates the transform of your TextBlock. The simplest way around that would be to either put the entrance transition on a parent element, or put the transform on one. You could simply wrap your TextBlock in a Grid to do it.

How display a text using silverlight in Windows phone 7

I need to display a text "welcome" on the right-bottom corner of a canvas with red colour
this is my xaml code
<Canvas x:Name="imageOne" Background="White" Width="480" Height="800" >
</Canvas>
please help me
Canvas defines an area within which you have to explicitly position TextBlock element by coordinates relative to the Canvas area. Means you have to do absolute positioning inside a Canvas.
If you really want to use a Canvas, you can better take a transparent Grid inside it and put a TextBlock inside that Grid.
Example:
<Canvas x:Name="imageOne" Background="White" Width="480" Height="800">
<Grid Width="480" Height="800">
<TextBlock Text="Visifire" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
</Grid>
</Canvas>
Please make sure that the Grid size is same as Canvas size.