-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from wieslawsoltes/StyledElementAction
Add StyledElementAction
- Loading branch information
Showing
31 changed files
with
225 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
samples/BehaviorsTestApplication/Views/Pages/BehaviorCollectionTemplateView.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<UserControl x:Class="BehaviorsTestApplication.Views.Pages.BehaviorCollectionTemplateView" | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:vm="using:BehaviorsTestApplication.ViewModels" | ||
x:CompileBindings="True" x:DataType="vm:MainWindowViewModel" | ||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="450"> | ||
<Design.DataContext> | ||
<vm:MainWindowViewModel /> | ||
</Design.DataContext> | ||
<ItemsControl ItemsSource="{Binding Items}"> | ||
<ItemsControl.Styles> | ||
<Style Selector="ItemsControl > ContentPresenter" x:DataType="vm:ItemViewModel"> | ||
<Setter Property="(Interaction.Behaviors)"> | ||
<BehaviorCollectionTemplate> | ||
<BehaviorCollection> | ||
<EventTriggerBehavior EventName="PointerPressed"> | ||
<ChangeAvaloniaPropertyAction TargetObject="{Binding $parent[ItemsControl]}" | ||
TargetProperty="{x:Static TemplatedControl.BackgroundProperty}" | ||
Value="{Binding Color}" /> | ||
</EventTriggerBehavior> | ||
<EventTriggerBehavior EventName="DoubleTapped"> | ||
<PopupAction> | ||
<Border Background="White" | ||
BorderBrush="Black" | ||
BorderThickness="1" | ||
Padding="10"> | ||
<StackPanel Orientation="Horizontal"> | ||
<TextBlock Text="Value: " /> | ||
<TextBlock Text="{Binding Value}" /> | ||
</StackPanel> | ||
</Border> | ||
</PopupAction> | ||
</EventTriggerBehavior> | ||
</BehaviorCollection> | ||
</BehaviorCollectionTemplate> | ||
</Setter> | ||
</Style> | ||
<Style Selector="ItemsControl > ContentPresenter"> | ||
<Setter Property="Background" Value="Transparent" /> | ||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> | ||
<Setter Property="Margin" Value="0" /> | ||
<Setter Property="Padding" Value="5" /> | ||
</Style> | ||
</ItemsControl.Styles> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate DataType="vm:ItemViewModel"> | ||
<TextBlock Text="{Binding Value}" /> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
</UserControl> |
17 changes: 17 additions & 0 deletions
17
samples/BehaviorsTestApplication/Views/Pages/BehaviorCollectionTemplateView.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace BehaviorsTestApplication.Views.Pages; | ||
|
||
public partial class BehaviorCollectionTemplateView : UserControl | ||
{ | ||
public BehaviorCollectionTemplateView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.