Based upon certain criteria I need to fade in or fade out items at the top of my page screen. These items contain an Image and possibly some buttons in the future. I came across http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.media.animation.edgeuithemetransition.aspx for WP8.1, but how can I accomplish this in WP8.0?
You should use Blend to create your own custom animation.Fade in or out can be achieved by adjusting the opacity level of your controls. You can follow this link. Another one here link
As an example, if you want to apply fade in effect on an Image here is a sample code.
<phone:PhoneApplicationPage.Resources>
<Storyboard x:Name="fadeInImage">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="image">
<EasingDoubleKeyFrame KeyTime="0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.3"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0.5"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.6" Value="0.7"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0.9"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</phone:PhoneApplicationPage.Resources>
and for playing that animation call it when necessary,
fadeInImage.Begin();
Related
I have a simple animation that i did using blend that moves a TextBlock to the left till it vanishes from the screen
<phone:PhoneApplicationPage.Resources>
<Storyboard x:Name="dtitle">
<DoubleAnimation Duration="0:0:2" To="-523.831" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="titleblock" d:IsOptimized="True"/>
</Storyboard>
</phone:PhoneApplicationPage.Resources>
I have one button 'Start' that should play the animation for about 0.25 secs and then pause it. So if the user presses the button, the TextBlock will move a tiny bit to the left and then stop. Is there something like
dtitle.Resume()
//wait 0.25 secs
dtitle.Pause()
or maybe
dtitle.PlayForSeconds(0.25)
The user should be able to use the UI within this period.
For example, using the Light Theme means that the back and appbar buttons are black.
However when using a darker app bar colour, the contrast of the buttons is stark.
Here's a screen grab, ignore the quality of the white one. http://i.imgur.com/2EzSd.png
Is there any way to directly access the styles that result in one theme's icons vs anothers?
Note: I'm building a C# + XAML app.
As a start the button will be looking somewhat like this:
Under the StandartStyles.xml you have to look for the style AppBarButtonStyle first to change your icon color find <Setter Property="Foreground" Value="{StaticResource AppBarItemForegroundThemeBrush}"/>
Now you replace {StaticResource AppBarItemForegroundThemeBrush} with the color you want you can use both white and #FFFFFFFF. now you have changed the visuals of your icon and you should have something like this
Now you need to style the text below this is done by finding the </TextBlock tag a few lines down and also changeing the forground property there
Now you have a nice looking icon but as soon as you mouse over it all turns quiet ugly agien. in order to change the diffrent states move down to the <VisualStateGroup x:Name="CommonStates"> tag here you will find a tag <VisualState x:Name="PointerOver"> as you might suspect this changes the properties of button when you hover the mouse over it.
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundGlyph" Storyboard.TargetProperty="Foreground">
<!-- the background of the actionbar-> !--><DiscreteObjectKeyFrame KeyTime="0" Value="yourBackgroundColor"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="Foreground">
<!-- the icon of the actionbar-> --><DiscreteObjectKeyFrame KeyTime="0" Value="yourActionBarIconColor"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
If you keep scrolling down you will find <VisualState x:Name="Pressed"> and so on.
You can take a look at the CSS that each theme uses by expanding the References node under the project in Visual Studio, then expanding the Windows Library for JavasScript 1.0 node and then the css folder.
The relevant lines for the colors of the AppBar seem to start on line 2621 of my ui-dark.css file. Also line 2448 specifies the color of for a .win-commandimage item, which is the icons for most appbar commands are. You should be able to override these settings in your project's stylesheet.
It turns out that Windows 8 just uses the Foreground colour (which it inherits from the selected theme style).
Which means that all you need do, is set the foreground to change the icon colour, winner!
The colours of the App Bar buttons for each theme are defined as resources which you can override. I've described the process at Windows 8 – Overriding Metro app resources.
For your approach is should be simple enough to grab the Light App Bar button resources and use them to override the Dark resources.
I have a behavior that changes the visual state based on the page's orientation (portrait/landscape). I have a ListBox with a somewhat complex DataTemplate for its ItemTemplate. Is it possible to change the ItemTemplate from a VisualState's Storyboard? My XAML karma is low, and Blend doesn't let me do it (it changes the original ItemTemplate, it doesn't add a storyboard entry).
And remember, this is for Windows Phone 7 (thus Silverlight 3).
I probably didn't get an answer because it was too obvious. I told you my XAML karma was low. Here is the solution. Simply add this ObjectAnimationUsingKeyFrames to your storyboard:
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ItemsControl.ItemTemplate)"
Storyboard.TargetName="PartakersListBox">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{StaticResource LandscapePartakerDataTemplate}" />
</ObjectAnimationUsingKeyFrames>
I didn't return to Blend yet, to see if the template was editable. Will update below.
i've a webbrowser in my application that only have to show without the user. can interact with it.
So if i set the IsEnabled = false, the browser become with a gray opacity on top of page and i don't want this.
How can i do?
Thanks.
If you want to disable user interactions, then you could try:
set IsHitTestVisible to false
or
position an Opacity 0.01 Canvas over the top of the web browser - this would be almost invisible and would stop the user from interacting with it.
To prevent the opacity change on the WebBrowser control when you set IsEnabled to false you will need to create a custom style for it. It's very simple and need only look like the following:
<Style x:Key="WebBrowserStyle1" TargetType="phone:WebBrowser">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="phone:WebBrowser">
<Border x:Name="StateContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Opacity="1">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WebBrowserStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="PresentationContainer"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
However, the user will not be able to interact with the contents. I'm not sure what you are trying to achieve if you want the control to be disabled but interactive. If what you are trying to do is stop the user interacting with the control, then the above would work, or setting IsHitTestVisible to false would achieve the same result, but with fewer changes :P
I'm building a custom control in Silverlight and I want one of the fields to animate to the value of a DependencyProperty when that property is changed. More specifically, I have particular item in my Control Template that I want to animate to the color of the Background whenever the background changes color. So, what I have is:
<ControlTemplate TargetType="local:MyType">
<Grid x:Name="PART_RootElement">
<Grid.Resources>
<Storyboard x:Name="PART_FillAnimation">
<ColorAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="PART_MainPath"
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
<EasingColorKeyFrame
x:Name="PATH_FillKeyframe"
KeyTime="00:00:01"
Value="{TemplateBinding Background}"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<!-- the rest of the template -->
I'm triggering the animation in the custom control code, but when the animation starts, it doesn't look like the Value is updating. I was just wondering if I'm missing something or if it is at all possible to apply TemplateBinding to resources in my ControlTemplate.
(I'm currently using a work-around of manually assigning the Background to the EasingColorKeyFrame Value, but the TemplateBinding solution would be so much cleaner.)
Have a look at Expression Blend Samples as a possible solution to your problem. There are a number of Interactivity classes that you could use within your ControlTemplate to create the effect your looking for. The documentation is not great, but descriptions in the Object Browser should give you some more clues :)
For example, I have a ListBox ItemTemplate that contains a ControlStoryboardAction Behaviour. The trigger for this Behaviour is a DataTrigger which fires when a DataContext field contains a specific value. (In my case when Severity=="High") The trigger then Plays a Storyboard within the ItemTemplate.
<i:Interaction.Triggers>
<is:DataTrigger Binding="{Binding Severity, Mode=OneWay}" Value="High">
<im:ControlStoryboardAction Storyboard="{StaticResource flashLight}" IsEnabled="True" />
</is:DataTrigger>
The following namespaces are referenced:
<i: - System.Windows.Interactivity
<is: - Expression.Samples.Interactivity (available from the link above. I am using the July 2009 release for SL3)
<im: - Microsoft.Expression.Interactivity.Media