Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1. <Window x:Class="XamlTestApplication.MainWindow"
  2. xmlns="https://github.com/perspex"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:vm="clr-namespace:XamlTestApplication.ViewModels;assembly=XamlTestApplicationPcl"
  5. xmlns:i="clr-namespace:Perspex.Xaml.Interactivity;assembly=Perspex.Xaml.Interactivity"
  6. xmlns:ia="clr-namespace:Perspex.Xaml.Interactions.Core;assembly=Perspex.Xaml.Interactions"
  7. xmlns:behaviors="clr-namespace:XamlTestApplication.Behaviors;assembly=XamlTestApplicationPcl"
  8. Title="XamlBehaviors Test Application" Width="800" Height="600">
  9. <Window.Styles>
  10. <Style Selector="TabItem">
  11. <Style.Resources>
  12. <SolidColorBrush x:Key="BlackBrush">Black</SolidColorBrush>
  13. <SolidColorBrush x:Key="GrayBrush">Gray</SolidColorBrush>
  14. <SolidColorBrush x:Key="RedBrush">Red</SolidColorBrush>
  15. <SolidColorBrush x:Key="BlueBrush">Blue</SolidColorBrush>
  16. <SolidColorBrush x:Key="YellowBrush">Yellow</SolidColorBrush>
  17. <SolidColorBrush x:Key="PinkBrush">Pink</SolidColorBrush>
  18. </Style.Resources>
  19. </Style>
  20. <Style Selector="TabItem.override">
  21. <Style.Resources>
  22. <SolidColorBrush x:Key="GrayBrush">Orange</SolidColorBrush>
  23. </Style.Resources>
  24. </Style>
  25. </Window.Styles>
  26. <Grid>
  27. <TabControl>
  28. <TabItem Header="CallMethodAction">
  29. <!-- TODO -->
  30. </TabItem>
  31. <TabItem Classes="override" Header="ChangePropertyAction">
  32. <Grid RowDefinitions="5*,*">
  33. <Rectangle Name="ChangePropertyRectangle" Grid.Row="0" Margin="5" Fill="{StyleResource PinkBrush}" Stroke="{StyleResource GrayBrush}" StrokeThickness="5"/>
  34. <Grid ColumnDefinitions="*,*" Grid.Row="1">
  35. <Button Name="button1" Content="Yellow" Grid.Column="0" Margin="5,0,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  36. <i:Interaction.Behaviors>
  37. <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button1}">
  38. <ia:ChangePropertyAction TargetObject="{Binding #ChangePropertyRectangle}" PropertyName="Fill" Value="{StyleResource YellowBrush}"/>
  39. </ia:EventTriggerBehavior>
  40. </i:Interaction.Behaviors>
  41. </Button>
  42. <Button Name="button2" Content="Pink" Grid.Column="1" Margin="5,0,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  43. <i:Interaction.Behaviors>
  44. <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button2}">
  45. <ia:ChangePropertyAction TargetObject="{Binding #ChangePropertyRectangle}" PropertyName="Fill" Value="{StyleResource PinkBrush}"/>
  46. </ia:EventTriggerBehavior>
  47. </i:Interaction.Behaviors>
  48. </Button>
  49. </Grid>
  50. </Grid>
  51. </TabItem>
  52. <TabItem Header="CustomAction">
  53. <!-- TODO -->
  54. </TabItem>
  55. <TabItem Header="CustomBehavior">
  56. <Grid Background="{StyleResource GrayBrush}">
  57. <Ellipse Fill="{StyleResource RedBrush}" Stroke="{StyleResource BlackBrush}" Height="125" Width="125" StrokeThickness="0" HorizontalAlignment="Stretch">
  58. <i:Interaction.Behaviors>
  59. <behaviors:DragPositionBehavior/>
  60. </i:Interaction.Behaviors>
  61. </Ellipse>
  62. </Grid>
  63. </TabItem>
  64. <TabItem Header="DataTriggerBehavior">
  65. <Grid RowDefinitions="5*,*">
  66. <Rectangle Name="DataTriggerRectangle" Grid.Row="0" Fill="{StyleResource BlueBrush}" Stroke="{StyleResource GrayBrush}" StrokeThickness="5">
  67. <i:Interaction.Behaviors>
  68. <ia:DataTriggerBehavior Binding="{Binding #slider.Value}" ComparisonCondition="GreaterThan" Value="50">
  69. <ia:ChangePropertyAction TargetObject="{Binding #DataTriggerRectangle}" PropertyName="Fill" Value="{StyleResource YellowBrush}"/>
  70. </ia:DataTriggerBehavior>
  71. <ia:DataTriggerBehavior Binding="{Binding #slider.Value}" ComparisonCondition="LessThanOrEqual" Value="50">
  72. <ia:ChangePropertyAction TargetObject="{Binding #DataTriggerRectangle}" PropertyName="Fill" Value="{StyleResource BlueBrush}"/>
  73. </ia:DataTriggerBehavior>
  74. </i:Interaction.Behaviors>
  75. </Rectangle>
  76. <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
  77. <TextBlock Text="{Binding #slider.Value}" VerticalAlignment="Center" Width="50" Foreground="{StyleResource GrayBrush}"/>
  78. <Slider Name="slider" Width="150" IsSnapToTickEnabled="True" TickFrequency="1"/>
  79. </StackPanel>
  80. </Grid>
  81. </TabItem>
  82. <TabItem Header="EventTriggerBehavior">
  83. <Grid RowDefinitions="Auto,100">
  84. <TextBox Name="textBox" Text="Hello" Grid.Row="0"/>
  85. <Button Name="button" Content="Change Property" Grid.Row="1">
  86. <i:Interaction.Behaviors>
  87. <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button}">
  88. <ia:ChangePropertyAction TargetObject="{Binding #textBox}" PropertyName="Text" Value="World"/>
  89. </ia:EventTriggerBehavior>
  90. </i:Interaction.Behaviors>
  91. </Button>
  92. </Grid>
  93. </TabItem>
  94. <TabItem Header="InvokeCommandAction">
  95. <!-- TODO -->
  96. </TabItem>
  97. </TabControl>
  98. </Grid>
  99. </Window>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement