Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved to examples to use Avalonia 11.0.4 #7

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5b2c093
Update the project
Philippe-Laval Aug 22, 2023
7b6639e
remove nuget file
Philippe-Laval Aug 22, 2023
b0147be
Update project
Philippe-Laval Aug 22, 2023
4cea921
clean code
Philippe-Laval Aug 22, 2023
4d77507
Upgrade project
Philippe-Laval Aug 22, 2023
011436e
Update the project
Philippe-Laval Aug 22, 2023
42f1d2a
upgrade demo
Philippe-Laval Aug 22, 2023
74fe56b
Upgrade project
Philippe-Laval Aug 22, 2023
821f6e2
Upgrade project
Philippe-Laval Aug 22, 2023
6eba944
Upgrade project
Philippe-Laval Aug 22, 2023
d42b571
upgrade project
Philippe-Laval Aug 22, 2023
9954e06
upgrade
Philippe-Laval Aug 22, 2023
242242e
Moved to Avalonia 11
Philippe-Laval Aug 22, 2023
6430d52
moved to Avalonia 11
Philippe-Laval Aug 22, 2023
64cdff2
Fix a typo
Philippe-Laval Aug 22, 2023
0d81576
net7.0-windows
Philippe-Laval Aug 22, 2023
2ac79fd
Move to Avalonia 11.0.4
Philippe-Laval Aug 22, 2023
9f66335
Avalonia 11
Philippe-Laval Aug 22, 2023
03d37a1
Problem with Avalonia 11 : ItemsPresenter has no Items property
Philippe-Laval Aug 22, 2023
c3f7414
Avalonia 11
Philippe-Laval Aug 22, 2023
d4135d1
Avalonia 11
Philippe-Laval Aug 22, 2023
ca37e1b
avalonia 11
Philippe-Laval Aug 23, 2023
690b470
Uses StyleKeyOverride to remove the warning
Philippe-Laval Aug 23, 2023
b7291a6
net7.0
Philippe-Laval Aug 23, 2023
de0479d
Avalonia 11
Philippe-Laval Aug 23, 2023
045fe93
Avalonia 11
Philippe-Laval Aug 23, 2023
a0dc33e
Avalonia 11
Philippe-Laval Aug 23, 2023
11f5a18
Avalonia 11
Philippe-Laval Aug 23, 2023
fa59b38
Avalonia 11
Philippe-Laval Aug 23, 2023
86daa8a
Avalonia 11
Philippe-Laval Aug 23, 2023
551e07a
Avalonia 11
Philippe-Laval Aug 23, 2023
174e85f
Avalonia 11.0.4
Philippe-Laval Aug 23, 2023
c44637e
Avalonia 11
Philippe-Laval Aug 23, 2023
a180f2c
Avalonia 11
Philippe-Laval Aug 23, 2023
1b25238
Avalonia 11
Philippe-Laval Aug 23, 2023
1f8a8a6
Update README.md
Philippe-Laval Aug 23, 2023
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
726 changes: 397 additions & 329 deletions .gitignore

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions CustomBehaviors/NP.Demos.CallActionBehaviorSample/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="NP.Demos.CallActionBehaviorSample.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
<FluentTheme />
</Application.Styles>
</Application>

Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,56 @@ namespace NP.Demos.CallActionBehaviorSample
public class CallActionOnEventBehavior
{
#region TheEvent Attached Avalonia Property
public static RoutedEvent GetTheEvent(IControl obj)
public static RoutedEvent GetTheEvent(Control obj)
{
return obj.GetValue(TheEventProperty);
}

public static void SetTheEvent(IControl obj, RoutedEvent value)
public static void SetTheEvent(Control obj, RoutedEvent value)
{
obj.SetValue(TheEventProperty, value);
}

public static readonly AttachedProperty<RoutedEvent> TheEventProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, RoutedEvent>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, RoutedEvent>
(
"TheEvent"
);
#endregion TheEvent Attached Avalonia Property


#region TargetObject Attached Avalonia Property
public static object GetTargetObject(IControl obj)
public static object GetTargetObject(Control obj)
{
return obj.GetValue(TargetObjectProperty);
}

public static void SetTargetObject(IControl obj, object value)
public static void SetTargetObject(Control obj, object value)
{
obj.SetValue(TargetObjectProperty, value);
}

public static readonly AttachedProperty<object> TargetObjectProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, object>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, object>
(
"TargetObject"
);
#endregion TargetObject Attached Avalonia Property


#region MethodToCall Attached Avalonia Property
public static string GetMethodToCall(IControl obj)
public static string GetMethodToCall(Control obj)
{
return obj.GetValue(MethodToCallProperty);
}

public static void SetMethodToCall(IControl obj, string value)
public static void SetMethodToCall(Control obj, string value)
{
obj.SetValue(MethodToCallProperty, value);
}

public static readonly AttachedProperty<string> MethodToCallProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, string>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, string>
(
"MethodToCall"
);
Expand All @@ -71,7 +71,7 @@ static CallActionOnEventBehavior()

private static void OnEventChanged(AvaloniaPropertyChangedEventArgs<RoutedEvent> args)
{
IControl el = (IControl) args.Sender;
Control el = (Control) args.Sender;

RoutedEvent? oldRoutedEvent = args.OldValue.Value as RoutedEvent;

Expand All @@ -96,7 +96,7 @@ private static void OnEventChanged(AvaloniaPropertyChangedEventArgs<RoutedEvent>
// TargetObject
private static void HandleRoutedEvent(object sender, RoutedEventArgs e)
{
IControl el = (IControl)sender;
Control el = (Control)sender;

// if TargetObject is not set, use DataContext as the target object
object? targetObject = GetTargetObject(el) ?? el.DataContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Border Background="Yellow"
HorizontalAlignment="Center"
VerticalAlignment="Center"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnterEvent}"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnteredEvent}"
local:CallActionOnEventBehavior.TargetObject="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}}"
local:CallActionOnEventBehavior.MethodToCall="MakeWindowBackgroundRed"
Width="50"
Expand All @@ -23,7 +23,7 @@
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnterEvent}"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnteredEvent}"
local:CallActionOnEventBehavior.TargetObject="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}}"
local:CallActionOnEventBehavior.MethodToCall="OpenDialog"
Width="50"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="NP.Demos.DoubleCallActionBehaviorSample.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
</Application.Styles>
x:Class="NP.Demos.DoubleCallActionBehaviorSample.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme/>
</Application.Styles>
</Application>

Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,61 @@ namespace NP.Demos.DoubleCallActionBehaviorSample
public class CallActionOnEventBehavior
{
#region TheEvent Attached Avalonia Property
public static RoutedEvent GetTheEvent(IControl obj)
public static RoutedEvent GetTheEvent(Control obj)
{
return obj.GetValue(TheEventProperty);
}

public static void SetTheEvent(IControl obj, RoutedEvent value)
public static void SetTheEvent(Control obj, RoutedEvent value)
{
obj.SetValue(TheEventProperty, value);
}

public static readonly AttachedProperty<RoutedEvent> TheEventProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, RoutedEvent>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, RoutedEvent>
(
"TheEvent"
);
#endregion TheEvent Attached Avalonia Property


#region TargetObject Attached Avalonia Property
public static object GetTargetObject(IControl obj)
public static object GetTargetObject(Control obj)
{
return obj.GetValue(TargetObjectProperty);
}

public static void SetTargetObject(IControl obj, object value)
public static void SetTargetObject(Control obj, object value)
{
obj.SetValue(TargetObjectProperty, value);
}

public static readonly AttachedProperty<object> TargetObjectProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, object>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, object>
(
"TargetObject"
);
#endregion TargetObject Attached Avalonia Property


#region MethodToCall Attached Avalonia Property
public static string GetMethodToCall(IControl obj)
public static string GetMethodToCall(Control obj)
{
return obj.GetValue(MethodToCallProperty);
}

public static void SetMethodToCall(IControl obj, string value)
public static void SetMethodToCall(Control obj, string value)
{
obj.SetValue(MethodToCallProperty, value);
}

public static readonly AttachedProperty<string> MethodToCallProperty =
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, IControl, string>
AvaloniaProperty.RegisterAttached<CallActionOnEventBehavior, Control, string>
(
"MethodToCall"
);


#endregion MethodToCall Attached Avalonia Property

static CallActionOnEventBehavior()
Expand All @@ -71,7 +73,7 @@ static CallActionOnEventBehavior()

private static void OnEventChanged(AvaloniaPropertyChangedEventArgs<RoutedEvent> args)
{
IControl el = (IControl) args.Sender;
Control el = (Control) args.Sender;

RoutedEvent? oldRoutedEvent = args.OldValue.Value as RoutedEvent;

Expand All @@ -96,7 +98,7 @@ private static void OnEventChanged(AvaloniaPropertyChangedEventArgs<RoutedEvent>
// TargetObject
private static void HandleRoutedEvent(object sender, RoutedEventArgs e)
{
IControl el = (IControl)sender;
Control el = (Control)sender;

// if TargetObject is not set, use DataContext as the target object
object? targetObject = GetTargetObject(el) ?? el.DataContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerLeaveEvent}"
<Grid local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerExitedEvent}"
local:CallActionOnEventBehavior.TargetObject="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}}"
local:CallActionOnEventBehavior.MethodToCall="RestoreBackground"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="50"
Height="50">
<Border Background="Yellow"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnterEvent}"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnteredEvent}"
local:CallActionOnEventBehavior.TargetObject="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}}"
local:CallActionOnEventBehavior.MethodToCall="MakeWindowBackgroundRed"
HorizontalAlignment="Stretch"
Expand All @@ -29,7 +29,7 @@
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnterEvent}"
local:CallActionOnEventBehavior.TheEvent="{x:Static InputElement.PointerEnteredEvent}"
local:CallActionOnEventBehavior.TargetObject="{Binding RelativeSource={RelativeSource AncestorType=local:MainWindow}}"
local:CallActionOnEventBehavior.MethodToCall="OpenDialog"
Width="50"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia" Version="11.0.4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.4" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.4" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
</ItemGroup>

</Project>
11 changes: 6 additions & 5 deletions CustomBehaviors/NP.Demos.DragBehaviorSample/App.axaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="NP.Demos.DragBehaviorSample.App">
<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml" />
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml" />
</Application.Styles>
x:Class="NP.Demos.DragBehaviorSample.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Styles>
<FluentTheme/>
</Application.Styles>
</Application>

Loading