Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Window x:Class="XamlTestApplication.MainWindow"
- xmlns="https://github.com/perspex"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:vm="clr-namespace:XamlTestApplication.ViewModels;assembly=XamlTestApplicationPcl"
- xmlns:i="clr-namespace:Perspex.Xaml.Interactivity;assembly=Perspex.Xaml.Interactivity"
- xmlns:ia="clr-namespace:Perspex.Xaml.Interactions.Core;assembly=Perspex.Xaml.Interactions"
- xmlns:behaviors="clr-namespace:XamlTestApplication.Behaviors;assembly=XamlTestApplicationPcl"
- Title="XamlBehaviors Test Application" Width="800" Height="600">
- <Window.Styles>
- <Style Selector="TabItem">
- <Style.Resources>
- <SolidColorBrush x:Key="BlackBrush">Black</SolidColorBrush>
- <SolidColorBrush x:Key="GrayBrush">Gray</SolidColorBrush>
- <SolidColorBrush x:Key="RedBrush">Red</SolidColorBrush>
- <SolidColorBrush x:Key="BlueBrush">Blue</SolidColorBrush>
- <SolidColorBrush x:Key="YellowBrush">Yellow</SolidColorBrush>
- <SolidColorBrush x:Key="PinkBrush">Pink</SolidColorBrush>
- </Style.Resources>
- </Style>
- <Style Selector="TabItem.override">
- <Style.Resources>
- <SolidColorBrush x:Key="GrayBrush">Orange</SolidColorBrush>
- </Style.Resources>
- </Style>
- </Window.Styles>
- <Grid>
- <TabControl>
- <TabItem Header="CallMethodAction">
- <!-- TODO -->
- </TabItem>
- <TabItem Classes="override" Header="ChangePropertyAction">
- <Grid RowDefinitions="5*,*">
- <Rectangle Name="ChangePropertyRectangle" Grid.Row="0" Margin="5" Fill="{StyleResource PinkBrush}" Stroke="{StyleResource GrayBrush}" StrokeThickness="5"/>
- <Grid ColumnDefinitions="*,*" Grid.Row="1">
- <Button Name="button1" Content="Yellow" Grid.Column="0" Margin="5,0,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
- <i:Interaction.Behaviors>
- <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button1}">
- <ia:ChangePropertyAction TargetObject="{Binding #ChangePropertyRectangle}" PropertyName="Fill" Value="{StyleResource YellowBrush}"/>
- </ia:EventTriggerBehavior>
- </i:Interaction.Behaviors>
- </Button>
- <Button Name="button2" Content="Pink" Grid.Column="1" Margin="5,0,5,5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
- <i:Interaction.Behaviors>
- <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button2}">
- <ia:ChangePropertyAction TargetObject="{Binding #ChangePropertyRectangle}" PropertyName="Fill" Value="{StyleResource PinkBrush}"/>
- </ia:EventTriggerBehavior>
- </i:Interaction.Behaviors>
- </Button>
- </Grid>
- </Grid>
- </TabItem>
- <TabItem Header="CustomAction">
- <!-- TODO -->
- </TabItem>
- <TabItem Header="CustomBehavior">
- <Grid Background="{StyleResource GrayBrush}">
- <Ellipse Fill="{StyleResource RedBrush}" Stroke="{StyleResource BlackBrush}" Height="125" Width="125" StrokeThickness="0" HorizontalAlignment="Stretch">
- <i:Interaction.Behaviors>
- <behaviors:DragPositionBehavior/>
- </i:Interaction.Behaviors>
- </Ellipse>
- </Grid>
- </TabItem>
- <TabItem Header="DataTriggerBehavior">
- <Grid RowDefinitions="5*,*">
- <Rectangle Name="DataTriggerRectangle" Grid.Row="0" Fill="{StyleResource BlueBrush}" Stroke="{StyleResource GrayBrush}" StrokeThickness="5">
- <i:Interaction.Behaviors>
- <ia:DataTriggerBehavior Binding="{Binding #slider.Value}" ComparisonCondition="GreaterThan" Value="50">
- <ia:ChangePropertyAction TargetObject="{Binding #DataTriggerRectangle}" PropertyName="Fill" Value="{StyleResource YellowBrush}"/>
- </ia:DataTriggerBehavior>
- <ia:DataTriggerBehavior Binding="{Binding #slider.Value}" ComparisonCondition="LessThanOrEqual" Value="50">
- <ia:ChangePropertyAction TargetObject="{Binding #DataTriggerRectangle}" PropertyName="Fill" Value="{StyleResource BlueBrush}"/>
- </ia:DataTriggerBehavior>
- </i:Interaction.Behaviors>
- </Rectangle>
- <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
- <TextBlock Text="{Binding #slider.Value}" VerticalAlignment="Center" Width="50" Foreground="{StyleResource GrayBrush}"/>
- <Slider Name="slider" Width="150" IsSnapToTickEnabled="True" TickFrequency="1"/>
- </StackPanel>
- </Grid>
- </TabItem>
- <TabItem Header="EventTriggerBehavior">
- <Grid RowDefinitions="Auto,100">
- <TextBox Name="textBox" Text="Hello" Grid.Row="0"/>
- <Button Name="button" Content="Change Property" Grid.Row="1">
- <i:Interaction.Behaviors>
- <ia:EventTriggerBehavior EventName="Click" SourceObject="{Binding #button}">
- <ia:ChangePropertyAction TargetObject="{Binding #textBox}" PropertyName="Text" Value="World"/>
- </ia:EventTriggerBehavior>
- </i:Interaction.Behaviors>
- </Button>
- </Grid>
- </TabItem>
- <TabItem Header="InvokeCommandAction">
- <!-- TODO -->
- </TabItem>
- </TabControl>
- </Grid>
- </Window>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement