Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion samples/BehaviorsTestApplication/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ namespace BehaviorsTestApplication.ViewModels;

public partial class ItemViewModel : ViewModelBase
{
public ItemViewModel(string value)
public ItemViewModel(string value, string color = "Black")
{
_value = value;
_color = color;
}

[Reactive]
Expand All @@ -15,5 +16,8 @@ public ItemViewModel(string value)
[Reactive]
public partial ObservableCollection<ItemViewModel>? Items { get; set; }

[Reactive]
public partial string? Color { get; set; }

public override string ToString() => _value ?? string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,47 +36,47 @@ public MainWindowViewModel()
ResetMoveCommand = ReactiveCommand.Create(() => Position = 100.0);
Items =
[
new("First Item")
new("First Item", "Red")
{
Items =
[
new("First Item Sub Item 1"), new("First Item Sub Item 2"), new("First Item Sub Item 3")
]
},

new("Second Item")
new("Second Item", "Green")
{
Items =
[
new("Second Item Sub Item 1"), new("Second Item Sub Item 2"), new("Second Item Sub Item 3")
]
},

new("Third Item")
new("Third Item", "Blue")
{
Items =
[
new("Third Item Sub Item 1"), new("Third Item Sub Item 2"), new("Third Item Sub Item 3")
]
},

new("Fourth Item")
new("Fourth Item", "Orange")
{
Items =
[
new("Fourth Item Sub Item 1"), new("Fourth Item Sub Item 2"), new("Fourth Item Sub Item 3")
]
},

new("Fifth Item")
new("Fifth Item", "Purple")
{
Items =
[
new("Fifth Item Sub Item 1"), new("Fifth Item Sub Item 2"), new("Fifth Item Sub Item 3")
]
},

new("Sixth Item")
new("Sixth Item", "Pink")
{
Items =
[
Expand Down
3 changes: 3 additions & 0 deletions samples/BehaviorsTestApplication/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@
<TabItem Header="Sliding Animation">
<pages:SlidingAnimationView />
</TabItem>
<TabItem Header="BehaviorCollectionTemplate">
<pages:BehaviorCollectionTemplateView />
</TabItem>
</TabControl>
</UserControl>
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>
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// <summary>
/// Adds a specified <see cref="AddClassAction.ClassName"/> to the <see cref="StyledElement.Classes"/> collection when invoked.
/// </summary>
public class AddClassAction : Avalonia.Xaml.Interactivity.Action
public class AddClassAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
/// <summary>
/// Identifies the <seealso cref="ClassName"/> avalonia property.
Expand All @@ -27,7 +27,7 @@ public class AddClassAction : Avalonia.Xaml.Interactivity.Action
AvaloniaProperty.Register<AddClassAction, bool>(nameof(RemoveIfExists));

/// <summary>
/// Gets or sets the class name that should be added. This is a avalonia property.
/// Gets or sets the class name that should be added. This is an avalonia property.
/// </summary>
public string ClassName
{
Expand All @@ -36,7 +36,7 @@ public string ClassName
}

/// <summary>
/// Gets or sets the target styled element that class name that should be added to. This is a avalonia property.
/// Gets or sets the target styled element that class name that should be added to. This is an avalonia property.
/// </summary>
[ResolveByName]
public StyledElement? StyledElement
Expand All @@ -46,7 +46,7 @@ public StyledElement? StyledElement
}

/// <summary>
/// Gets or sets the flag indicated whether to remove the class if already exists before adding. This is a avalonia property.
/// Gets or sets the flag indicated whether to remove the class if already exists before adding. This is an avalonia property.
/// </summary>
public bool RemoveIfExists
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// An action that will change a specified Avalonia property to a specified value when invoked.
/// </summary>
[RequiresUnreferencedCode("This functionality is not compatible with trimming.")]
public class ChangeAvaloniaPropertyAction : Avalonia.Xaml.Interactivity.Action
public class ChangeAvaloniaPropertyAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
/// <summary>
/// Identifies the <seealso cref="TargetProperty"/> avalonia property.
Expand All @@ -32,7 +32,7 @@ public class ChangeAvaloniaPropertyAction : Avalonia.Xaml.Interactivity.Action
AvaloniaProperty.Register<ChangeAvaloniaPropertyAction, object?>(nameof(Value));

/// <summary>
/// Gets or sets the name of the Avalonia property to change. This is a avalonia property.
/// Gets or sets the name of the Avalonia property to change. This is an avalonia property.
/// </summary>
public AvaloniaProperty? TargetProperty
{
Expand All @@ -41,7 +41,7 @@ public AvaloniaProperty? TargetProperty
}

/// <summary>
/// Gets or sets the value to set. This is a avalonia property.
/// Gets or sets the value to set. This is an avalonia property.
/// </summary>
public object? Value
{
Expand All @@ -51,7 +51,7 @@ public object? Value

/// <summary>
/// Gets or sets the Avalonia object whose property will be changed.
/// If <seealso cref="TargetObject"/> is not set or cannot be resolved, the sender of <seealso cref="Execute"/> will be used. This is a avalonia property.
/// If <seealso cref="TargetObject"/> is not set or cannot be resolved, the sender of <seealso cref="Execute"/> will be used. This is an avalonia property.
/// </summary>
[ResolveByName]
public AvaloniaObject? TargetObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// <summary>
///
/// </summary>
public class CloseNotificationAction : Avalonia.Xaml.Interactivity.Action
public class CloseNotificationAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
/// <summary>
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// <summary>
/// Focuses the associated or target control when executed.
/// </summary>
public class FocusControlAction : Avalonia.Xaml.Interactivity.Action
public class FocusControlAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
/// <summary>
/// Identifies the <seealso cref="TargetControl"/> avalonia property.
Expand All @@ -16,7 +16,7 @@ public class FocusControlAction : Avalonia.Xaml.Interactivity.Action
AvaloniaProperty.Register<FocusControlAction, Control?>(nameof(TargetControl));

/// <summary>
/// Gets or sets the target control. This is a avalonia property.
/// Gets or sets the target control. This is an avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Xaml.Interactions.Custom/Actions/PopupAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// An action that displays a <see cref="Popup"/> for the associated control when executed.
/// </summary>
/// <remarks>If the associated control is of type <see cref="Control"/> than popup inherits control <see cref="StyledElement.DataContext"/>.</remarks>
public class PopupAction : Avalonia.Xaml.Interactivity.Action
public class PopupAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
private Popup? _popup;

Expand All @@ -21,7 +21,7 @@ public class PopupAction : Avalonia.Xaml.Interactivity.Action
AvaloniaProperty.Register<PopupAction, Control?>(nameof(Child));

/// <summary>
/// Gets or sets the popup Child control. This is a avalonia property.
/// Gets or sets the popup Child control. This is an avalonia property.
/// </summary>
[Content]
public Control? Child
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Avalonia.Xaml.Interactions.Custom;
/// <summary>
/// Removes a specified <see cref="RemoveClassAction.ClassName"/> from <see cref="StyledElement.Classes"/> collection when invoked.
/// </summary>
public class RemoveClassAction : Avalonia.Xaml.Interactivity.Action
public class RemoveClassAction : Avalonia.Xaml.Interactivity.StyledElementAction
{
/// <summary>
/// Identifies the <seealso cref="ClassName"/> avalonia property.
Expand All @@ -21,7 +21,7 @@ public class RemoveClassAction : Avalonia.Xaml.Interactivity.Action
AvaloniaProperty.Register<RemoveClassAction, StyledElement?>(nameof(StyledElement));

/// <summary>
/// Gets or sets the class name that should be removed. This is a avalonia property.
/// Gets or sets the class name that should be removed. This is an avalonia property.
/// </summary>
public string ClassName
{
Expand All @@ -30,7 +30,7 @@ public string ClassName
}

/// <summary>
/// Gets or sets the target styled element that class name that should be removed from. This is a avalonia property.
/// Gets or sets the target styled element that class name that should be removed from. This is an avalonia property.
/// </summary>
[ResolveByName]
public StyledElement? StyledElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ButtonClickEventTriggerBehavior : StyledElementTrigger<Button>
AvaloniaProperty.Register<ButtonClickEventTriggerBehavior, KeyModifiers>(nameof(KeyModifiers));

/// <summary>
/// Gets or sets the required key modifiers to execute <see cref="Button.ClickEvent"/> event handler. This is a avalonia property.
/// Gets or sets the required key modifiers to execute <see cref="Button.ClickEvent"/> event handler. This is an avalonia property.
/// </summary>
public KeyModifiers KeyModifiers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class RoutedEventTriggerBehavior : StyledElementTrigger<Interactive>
private bool _isAttached;

/// <summary>
/// Gets or sets routing event to listen for. This is a avalonia property.
/// Gets or sets routing event to listen for. This is an avalonia property.
/// </summary>
public RoutedEvent? RoutedEvent
{
Expand All @@ -42,7 +42,7 @@ public RoutedEvent? RoutedEvent
}

/// <summary>
/// Gets or sets the routing event <see cref="RoutingStrategies"/>. This is a avalonia property.
/// Gets or sets the routing event <see cref="RoutingStrategies"/>. This is an avalonia property.
/// </summary>
public RoutingStrategies RoutingStrategies
{
Expand All @@ -52,7 +52,7 @@ public RoutingStrategies RoutingStrategies

/// <summary>
/// Gets or sets the source object from which this behavior listens for events.
/// If <seealso cref="SourceInteractive"/> is not set, the source will default to <seealso cref="IBehavior.AssociatedObject"/>. This is a avalonia property.
/// If <seealso cref="SourceInteractive"/> is not set, the source will default to <seealso cref="IBehavior.AssociatedObject"/>. This is an avalonia property.
/// </summary>
[ResolveByName]
public Interactive? SourceInteractive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static ValueChangedTriggerBehavior()
AvaloniaProperty.Register<ValueChangedTriggerBehavior, object?>(nameof(Binding));

/// <summary>
/// Gets or sets the bound object that the <see cref="ValueChangedTriggerBehavior"/> will listen to. This is a avalonia property.
/// Gets or sets the bound object that the <see cref="ValueChangedTriggerBehavior"/> will listen to. This is an avalonia property.
/// </summary>
public object? Binding
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public sealed class DragControlBehavior : StyledElementBehavior<Control>
private Point _previous;

/// <summary>
/// Gets or sets the target control to be moved around instead of <see cref="IBehavior.AssociatedObject"/>. This is a avalonia property.
/// Gets or sets the target control to be moved around instead of <see cref="IBehavior.AssociatedObject"/>. This is an avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class HideOnKeyPressedBehavior : StyledElementBehavior<Control>
AvaloniaProperty.Register<HideOnKeyPressedBehavior, Key>(nameof(Key), Key.Escape);

/// <summary>
/// Gets or sets the target control. This is a avalonia property.
/// Gets or sets the target control. This is an avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
Expand All @@ -33,7 +33,7 @@ public Control? TargetControl
}

/// <summary>
/// Gets or sets the key. This is a avalonia property.
/// Gets or sets the key. This is an avalonia property.
/// </summary>
public Key Key
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class HideOnLostFocusBehavior : StyledElementBehavior<Control>
AvaloniaProperty.Register<HideOnLostFocusBehavior, Control?>(nameof(TargetControl));

/// <summary>
/// Gets or sets the target control. This is a avalonia property.
/// Gets or sets the target control. This is an avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public abstract class ShowBehaviorBase : AttachedToVisualTreeBehavior<Control>
AvaloniaProperty.Register<ShowBehaviorBase, RoutingStrategies>(nameof(EventRoutingStrategy), RoutingStrategies.Bubble);

/// <summary>
/// Gets or sets the target control. This is a avalonia property.
/// Gets or sets the target control. This is an avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ShowOnKeyDownBehavior : ShowBehaviorBase
AvaloniaProperty.Register<ShowOnKeyDownBehavior, KeyGesture?>(nameof(Gesture));

/// <summary>
/// Gets or sets the key. This is a avalonia property.
/// Gets or sets the key. This is an avalonia property.
/// </summary>
public Key? Key
{
Expand Down
Loading
Loading