Nevermind. The issue was that I needed to disable transitions for the contained object which happened to be a Listview. had to disable the ItemContainerTransitions collection.
I dynamically add and remove elements from a Canvas element. When I do, the elements do that nice automatic animation which is completely unneeded for me (since I do all my own animation in this case).
I tried putting an empty TransitionCollection in the Canvas element in XAML and it does not seem to have any effect. I also tried adding an EntranceTransition with a zero offset, but that did not help either.
How do I tell Canvas not to animate my elements as they are added?
Here's what I tried:
<Canvas.Transitions>
<TransitionCollection>
<AddDeleteThemeTransition/>
<EntranceThemeTransition FromHorizontalOffset="0"/>
</TransitionCollection>
</Canvas.Transitions>
and
<Canvas.Transitions>
<TransitionCollection>
</TransitionCollection>
</Canvas.Transitions>
Related
I am trying to get a RichEditBox to take over the entire width of the app window and to be responsive to window resizing, so far the code I have is the following:
<RichEditBox HorizontalAlignment="Stretch"
TextWrapping="WrapWholeWords"
Height="250"
Name="Intro"/>
What I am getting from the code above is this:
Any ideas on how can I get this to work? Why is it that I tell the text to wrap and it doesn't follow?
UPDATE
I also tried this:
<RichEditBox HorizontalAlignment="Stretch"
Height="250"
Name="Intro"/>
But the result is:
The problem that I am having is that it seems that HorizontalAlignment="Stretch" does not really do anything. The only way I am able to set a decent width is by hard-coding it, for example: Width="600". But if I do this my UI will not respond correctly to resizing. I also tried HorizontalContentAlingment="Stretch" but the result is exactly the same.
How can I get my RichEditBox take up all the available Width and Wrap at the same time?
If you look at the documentation of RichEditBox.TextWrapping, you'll notice that WrapWholeWords is invalid. You have to use
<RichEditBox TextWrapping="Wrap"/>
-or-
<RichEditBox TextWrapping="NoWrap"/>
Since Wrap is the default value, you can drop the property.
<RichEditBox HorizontalAlignment="Stretch"
Height="250"
Name="Intro"/>
Edit: in reply to the updated question:
A control only takes the width of it's parent control. Some container controls (e.g. Grid) automatically take the full width available, while others (e.g. StackPanel) only take the required size of it's children. Using HorizontalAlignment="Stretch" in combination with a StackPanel as a parent control, will only use the MinWidth property instead of the full available width on your screen. Sometimes you can't directly see this issue, e.g. when your control is inside an itemtemplate of a ListView. Use the Live Visual Tree in Visual Studio to find the parent containers and locate the issue.
So in short: make sure your RichEditBox is inside a Grid (or similar control) instead of a StackPanel.
I created an ItemsControl element in my XAML page. I added an animation when the new items are being added through the following style:
<Style TargetType="ItemsControl" x:Key="NotificationsList">
<Setter Property="ItemContainerTransitions">
<Setter.Value>
<TransitionCollection>
<EntranceThemeTransition FromHorizontalOffset="-40" FromVerticalOffset="0" />
</TransitionCollection>
</Setter.Value>
</Setter>
</Style>
This is great; the items slide in from the left as they get added.
Now, I need to add an animation for removal of items. I have two challenges:
How to apply an animation on an item when the object is removed from the bound ObservableCollection? For example, something like ExitingThemeTransition.
The items that get removed are always from the bottom of the ItemsControl. This causes the remaining items to just drop down by the height of the removed items, which seems to be difficult to follow. How do I make the animation that would gracefully move down the remaining items? Is that possible?
I am using Universal Windows Apps API (Windows 10 / WinRT). Thanks!
I was wondering whether it's possible to have an animation whereby the Text value of a TextBlock switches between two values. The FontFamily for the TextBlock is an icon font and so what I'm aiming to pull off is essentially an animated icon.
For example:
<StackPanel
x:Name="PART_LayoutRoot">
<StackPanel.Resources>
<Storyboard
x:Name="PART_Animation">
<<STRING>Animation
Storyboard.TargetName="progressBarIcon"
Storyboard.TargetProperty="Text"
From="hi" To="bye" Duration="0:0:1"
AutoReverse="True"/>
</Storyboard>
</StackPanel.Resources>
<TextBlock
x:Name="progressBarIcon"/>
</StackPanel>
Does an animation type exists that will enable me to achieve what I'm after? If not, is there any other way to do so without using a storyboard animation? I'm planning to use this animation until a certain action completes i.e. a custom busy indicator.
Any help/guidance is much appreciated.
Animating string properties is not possible this way for two reasons - there is no clear way how a string animation should look, and also the value of the Text property would be unclear/invalid during the animation.
To achieve the result you want, you will need to create two TextBlocks, one with full Opacity="1" and one with Opacity="0" and then animate these opacities - one to fade out, one to fade in - this is possible normally with the DoubleAnimation so you will not run into any issues here.
I have a Canvas that overrides PointerMoved event do some stuff if the user "paints" on it. Now I'm trying to move this Canvas inside a ScrollViewer to add Zoom and Scroll effects which works perfectly.
<ScrollViewer x:Name="MainScrollViewer" Grid.Column="1"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
ZoomMode="Enabled" MinZoomFactor="0.5" MaxZoomFactor="2.0" >
<Canvas x:Name="MainCanvas" Background="#000000"
HorizontalAlignment="Left" VerticalAlignment="Top"
PointerMoved="MainCanvas_PointerMoved" />
</ScrollViewer>
However, the ScrollViewer captures all the Pointer move Events and this caused the main paint procedure not working anymore.
Any idea on how to fix this?
Drawing with touch while still allowing zooming/panning - this is currently not supported in XAML. You will need to turn OFF zooming/panning in order to be able to draw with Pointer events and it is not possible to obtain system zooming and panning behaviors simultaneously with custom manipulations. You can however try to use Manipulation events by setting ManipulationMode=All and handle two finger scrolling and pinch zoom using Scale and Translate values manually.
See more at: Touch based drawing app with a Canvas inside a ScrollViewer
I didn't work with canvas and scrollview but I think which I found will help you :)
There is a trick! You can add a tool button (like hand) to switch in two conditions.
First condition enable drawing: you can disable HorizontalScrollMode and VerticalScrollMode of ScrollViewer which gives you ability to use pointer events of Canvas.
In second one you should enable the HorizontalScrollMode and VerticalScrollMode for ScrollViewer, and it works!
To change ScrollViewer properties programmatically:
MainScrollViewer.HorizontalScrollMode = ScrollMode.Auto;
MainScrollViewer.VerticalScrollMode = ScrollMode.Auto;
MainScrollViewer.ZoomMode = ZoomMode.Enabled;
So I have come to that point where I am saying to myself over and over again I am missing some basic stuff.
I have a ScrollViewer with a RichTextBlock that converts HTML to the content.
Everything shows up as expected but I can't scroll! I had the VerticalScrollBarVisibility to Hidden but I have taken that out. After seeing this anwsear in StackOverflow I have stoped with the following code:
<ScrollViewer VerticalAlignment="Stretch"
HorizontalScrollMode="Disabled"
VerticalScrollBarVisibility="Visible"
VerticalScrollMode="Auto"
ZoomMode="Disabled"
Padding="52"
Background="#60000000" >
<RichTextBlock rtbx:Properties.Html="{Binding TextHTML}"
TextAlignment="Justify"
FontSize="20" />
</ScrollViewer>
It also seems that the PanningMode is not avaiable in Windows 8 but I belive that it is still the expected behaviour to scroll with the touch.
I have tried to put the ManipulationMode to All in the ScrollViewer and also tried to set to none in the RichTextBlock. However, I got no sucess with those approaches.
Removing the manipulation modes and isolating the problem and simplifing the "options" I was using led me to the conclusion that the ScrollViewer wasn't the issue.
The problem was: I had was a Control that was on top of the ScrollViewer that was hidden (opacity = 0). This Control swallowed all the events that I was needing in the ScrollViewer. Basic mistake.
I had to put the Visibility equals to Collapsed.