Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. xmlns:local="clr-namespace:wpf_test"
  2.  
  3. <Window x:Class="wpf_test.MainWindow"
  4. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  5. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  6. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  7. xmlns:local="clr-namespace:wpf_test"
  8. Title="MainWindow" Height="350" Width="525"
  9. x:Name="MySlidingWindow">
  10.  
  11. <Window.Resources>
  12. <sys:Int32 x:Key="WindowPosition">30</sys:Int32>
  13. <local:WindowPositionConverter x:Key="WindowPosConv" />
  14. </Window.Resources>
  15.  
  16. <Window.Triggers>
  17. <EventTrigger RoutedEvent="Loaded" SourceName="MySlidingWindow">
  18. <EventTrigger.Actions>
  19. <BeginStoryboard>
  20. <Storyboard>
  21. <DoubleAnimation
  22. Storyboard.TargetName="MySlidingWindow"
  23. Storyboard.TargetProperty="Left"
  24. From="{x:Static SystemParameters.FullPrimaryScreenWidth}"
  25. To="{Binding Source={StaticResource WindowPosition}, Converter={StaticResource WindowPosConv}}"
  26. Duration="0:0:1.5"/>
  27. </Storyboard>
  28. </BeginStoryboard>
  29. </EventTrigger.Actions>
  30. </EventTrigger>
  31. </Window.Triggers>
  32.  
  33. <Grid>
  34.  
  35. </Grid>
  36. </Window>
  37.  
  38. using System;
  39. using System.Globalization;
  40. using System.Windows.Data;
  41.  
  42. namespace wpf_test
  43. {
  44. class WindowPositionConverter : IValueConverter
  45. {
  46. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  47. {
  48. var pos = (int) value;
  49. var result = System.Windows.SystemParameters.PrimaryScreenWidth/100*pos;
  50. return result;
  51. }
  52.  
  53. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  54. {
  55. throw new NotImplementedException();
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement