Windows phone 8: navigation animation - c#

How to animate navigation process like "pushViewController" in iOS.
I mean animage navigation from left to right.
Thank you.

You have to use the Windows Phone Toolkit to animate navigation between pages. There's no builtin feature to do such a thing.
You will have to configure animations in each page you want an animation to happen (You will also be able to put these configurations into Styles to share them across your App).
You'll find a great step by step guide in here. (It was intended for WP7 at first but it's still valid for WP8)
Finally, the Style corresponding to the effect that you are trying to reproduce should look like this one :
<Style x:Key="TransitionPageSlideStyle" TargetType="phone:PhoneApplicationPage">
<Setter Property="slt:TransitionService.NavigationInTransition">
<Setter.Value>
<slt:NavigationInTransition>
<slt:NavigationInTransition.Backward>
<slt:SlideTransition Mode="SlideRightFadeIn"/>
</slt:NavigationInTransition.Backward>
<slt:NavigationInTransition.Forward>
<slt:SlideTransition Mode="SlideLeftFadeIn"/>
</slt:NavigationInTransition.Forward>
</slt:NavigationInTransition>
</Setter.Value>
</Setter>
<Setter Property="slt:TransitionService.NavigationOutTransition">
<Setter.Value>
<slt:NavigationOutTransition>
<slt:NavigationOutTransition.Backward>
<slt:SlideTransition Mode="SlideRightFadeOut"/>
</slt:NavigationOutTransition.Backward>
<slt:NavigationOutTransition.Forward>
<slt:SlideTransition Mode="SlideLeftFadeOut"/>
</slt:NavigationOutTransition.Forward>
</slt:NavigationOutTransition>
</Setter.Value>
</Setter>
</Style>

Related

Change Button Foreground in :pointerover and :pressed states

In fluent theme i can't change button Foregrounds in this states. In Github i find this code:
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
...
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" />
</Style>
But my project can't build with Foreground on ContentPresenter#PART_ContentPresenter.
ContentPresenter does not have a Foreground property. If you target a TextBlock you could use attached property TextBlock.Foreground. If not, there are child and descendant selectors you may want to take look at.
Also the nested selector ^ does not seem to be documented (it's pretty new it seems), maybe it would be safer to just use name of the control (Button in your case) for now.

How to change visual behavior of a button in WPF?

I noticed that on Windows 10, the appearance of controls shown by the OS looks much more appealing than the defaults on Winforms/WPF. For example, The selected OS button has a thicker blue border, and a more interactive "feel" to it, while the default WPF button appears as a simple grey box:
OS:
WPF:
Is there a way to somehow change the "theme" of a button in WPF to behave similarly to the most OS-displayed buttons, without having to implement this behaviour manually?
You can get similar button styles using Windows UWP.
In WPF, you can check out the Modern UI(MUI) in MSDN site.
It can produce similar results. I have been working with mui for a couple of months and it really helped me to satisfy my client who wanted to have a Windows 10 like UI experience. I had to create tiles like in start menu also. MUI did a great job for me.
Get the MUI from Github. Modern UI for WPF
Also I had tried devexpress and telerik controls. Have a look at them too.
You can use DevExpress to get themes for your form. Or you can implement your own by adding borders around every button and change its Color/Visibility on MouseDown and MouseUp event handlers
Define a Style within Window.Resources with TargetType="Button" so that it affects all the buttons in that window. For example, although the default WPF button has mouseover colour change and a focus rectangle, it does not move "inwards" on MouseDown, so this example shows how to do this:
<Window.Resources>
<!--A Style that affects all Buttons-->
<Style TargetType="Button">
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property= "RenderTransform">
<Setter.Value>
<TransformGroup>
<ScaleTransform ScaleX="0.99" ScaleY="0.99"/>
<TranslateTransform X="2" Y="2"/>
</TransformGroup>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness">
<Setter.Value>
<Thickness Left="2" Right="2" Top="2" Bottom="2"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
Insert this after the Window attributes and before the Grid or other container tag.

Setting Design Time Size for Custom Control

How do you set the Design Time Width and Height of a custom control?
I have created a custom ItemsControl, i.e. (contents of generic.xaml)
<Style TargetType="{x:Type MyItemsControl}" >
<Setter Property="Height" Value="24" />
<Setter Property="Width" Value="160" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MyItemsControl}" >
<Grid>
...
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
...
</Style>
And it works all nicely and all, however if I drag the control from the ToolBox onto my window the default size of my control is: Height = 100 and Width = 200. How do I set the design time size so that when I drag the control from the Toolbox to window the default size is 24 and 160 respectively?
May b it helps u..........
for that firstly u have to make ur own controls by inheriting it with
original controls and set Hieght,width and whatever you want in your
custom control .........after this when u drag ur own made control
form toolbox to ur form it will set by ur way whatever u wanted.......
This is a setting within Visual Studio itself, and there doesn't seem to be a way to change it, nor is Microsoft planning on changing it.
Source: A user reported this issue to Microsoft online and a Microsoft employee responded and marked the issue as "Won't Fix".

Allowing Copy/Paste for XamDataGrid across application

I'm working on an application that had many infrgistics XamDataGrids. I'd like to at least provide Copy to clipboard abilities on them. This can easily be achieved in the XAML for each grid, with:
<igDP:XamDataGrid DataSource="{Binding}" >
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AllowClipboardOperations="Copy"/>
</igDP:XamDataGrid.FieldLayoutSettings>
</igDP:XamDataGrid>
However, I would like all XamDataGrids in the application to allow this Copy to clipboard feature. I thought styling would be the answer, but for some reason, this does not work:
<Style TargetType="{x:Type igDP:FieldLayoutSettings}">
<Setter Property="AllowClipboardOperations" Value="Copy" />
</Style>
I've tried many variations on the above, but nothing seems to take, and there are no error messages. Any help would be really appreciated.
This is untested but perhaps you require the fully qualified name as below: (including the XamDataGrid.)
<Style TargetType="{x:Type igDP:XamDataGrid.FieldLayoutSettings}">
<Setter Property="AllowClipboardOperations" Value="Copy" />
</Style>
This question is old, but I just ran across it.
Anyway, the TargetType of your style will be XamDataGrid.
The property you are setting is FieldLayoutSettings.
<Style TargetType="{x:Type igDp:XamDataGrid}">
<Setter Property="FieldLayoutSettings">
<Setter.Value>
<igDp:FieldLayoutSettings AllowClipboardOperations="Copy"/>
</Setter.Value>
</Setter>
</Style>
Is this style defined in a place (like App.xaml) where every XamDataGrid can inherit it?
Have you tried defining this style in the same XAML file as a XamDataGrid that might use it? I would start by seeing if you could make this work as a local style in one specific place.

Play a sound when button pressed application wide

I have a WPF application that should be used on a touch screen. I have been asked to play a sound when a button is pressed on the screen, for the whole application.
My idea was to create a style to do this, include the resource dictionnary in my app.It works quite well.
However, this style is in a separate DLL and I would like my main application to change the path of the sound file (BoutonClickSound Url below). But I could not find a way to do it.
I have tried several ugly things like :
System.Windows.Application.Current.Resources.MergedDictionaries[0]["BoutonClickSound"] = new Uri(m_MainVM.ButClickSoundPath);
System.Windows.Application.Current.Resources.MergedDictionaries[0].MergedDictionaries[0]["BoutonClickSound"] = new Uri(m_MainVM.ButClickSoundPath);
But none of them seems to work...
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework"
xmlns:sys="clr-namespace:System;assembly=System">
<sys:Uri x:Key="BoutonClickSound">c:\buttonclick.wav</sys:Uri>
<Style TargetType="{x:Type FrameworkElement}" x:Key="SoundButton">
<Style.Triggers>
<EventTrigger RoutedEvent="PreviewMouseDown">
<SoundPlayerAction x:Name="SoundPlayer" Source="{DynamicResource BoutonClickSound}" />
</EventTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type primitives:Selector}" x:Key="SoundSelectionChange">
<Style.Triggers>
<EventTrigger RoutedEvent="SelectionChanged">
<SoundPlayerAction x:Name="SoundPlayer" Source="{DynamicResource BoutonClickSound}" />
</EventTrigger>
</Style.Triggers>
</Style>
Any idea how to do this ?
Thank you.
Just declare a local resource with the same key.
If you want it globally in your application, you can add it to a MergedDictionary after you include the MergedDictionary from your library.
Add another entry like this:
<sys:Uri x:Key="BoutonClickSound">c:\differentfile.wav</sys:Uri>
And it should cause your style to use that file instead.
Edit:
To set the resource in the code-behind, first you must add it to the local resource dictionary:
Resources.Add("BoutonClickSound", new Uri("your uri here"));
After you add it, if you want to later change it, you can't re-add it, you have to modify it:
Resources["BoutonClickSound"] = new Uri("your uri here");

Categories