Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xmlns:local="clr-namespace:wpf_test"
- <Window x:Class="wpf_test.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:sys="clr-namespace:System;assembly=mscorlib"
- xmlns:local="clr-namespace:wpf_test"
- Title="MainWindow" Height="350" Width="525"
- x:Name="MySlidingWindow">
- <Window.Resources>
- <sys:Int32 x:Key="WindowPosition">30</sys:Int32>
- <local:WindowPositionConverter x:Key="WindowPosConv" />
- </Window.Resources>
- <Window.Triggers>
- <EventTrigger RoutedEvent="Loaded" SourceName="MySlidingWindow">
- <EventTrigger.Actions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation
- Storyboard.TargetName="MySlidingWindow"
- Storyboard.TargetProperty="Left"
- From="{x:Static SystemParameters.FullPrimaryScreenWidth}"
- To="{Binding Source={StaticResource WindowPosition}, Converter={StaticResource WindowPosConv}}"
- Duration="0:0:1.5"/>
- </Storyboard>
- </BeginStoryboard>
- </EventTrigger.Actions>
- </EventTrigger>
- </Window.Triggers>
- <Grid>
- </Grid>
- </Window>
- using System;
- using System.Globalization;
- using System.Windows.Data;
- namespace wpf_test
- {
- class WindowPositionConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- var pos = (int) value;
- var result = System.Windows.SystemParameters.PrimaryScreenWidth/100*pos;
- return result;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement