-
-
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.
- Loading branch information
1 parent
872be7f
commit 5532cdb
Showing
3 changed files
with
68 additions
and
0 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
48 changes: 48 additions & 0 deletions
48
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,48 @@ | ||
<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"> | ||
<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); | ||
} | ||
} |