mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-07 07:56:07 +02:00
Content update - Add attached property snippet tests (user story 1878471) (#1224)
* Add snippet test and update type * Add snippet test and update type * Update to .NET to 6.0 * Update accessor signatures
This commit is contained in:
+9
-2
@@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CodeSampleCsharp
|
||||
@@ -13,6 +14,12 @@ namespace CodeSampleCsharp
|
||||
InitializeComponent();
|
||||
|
||||
SetAttachedPropertyInCode();
|
||||
|
||||
// Test get/set accessors.
|
||||
Aquarium aquarium = new();
|
||||
Aquarium.SetHasFish(aquarium, true);
|
||||
bool hasFish = Aquarium.GetHasFish(aquarium);
|
||||
Debug.WriteLine($"Has fish: {hasFish}");
|
||||
}
|
||||
|
||||
public static void SetAttachedPropertyInCode()
|
||||
@@ -32,7 +39,7 @@ namespace CodeSampleCsharp
|
||||
}
|
||||
|
||||
//<RegisterAttachedProperty>
|
||||
public class Aquarium : DependencyObject
|
||||
public class Aquarium : UIElement
|
||||
{
|
||||
// Register an attached dependency property with the specified
|
||||
// property name, property type, owner type, and property metadata.
|
||||
|
||||
+7
-1
@@ -10,6 +10,12 @@
|
||||
InitializeComponent()
|
||||
|
||||
SetAttachedPropertyInCode()
|
||||
|
||||
' Test get/set accessors.
|
||||
Dim aquarium As New Aquarium()
|
||||
aquarium.SetHasFish(aquarium, True)
|
||||
Dim hasFish As Boolean = aquarium.GetHasFish(aquarium)
|
||||
Debug.WriteLine($"Has fish: {hasFish}")
|
||||
End Sub
|
||||
|
||||
Public Shared Sub SetAttachedPropertyInCode()
|
||||
@@ -30,7 +36,7 @@
|
||||
|
||||
'<RegisterAttachedProperty>
|
||||
Public Class Aquarium
|
||||
Inherits DependencyObject
|
||||
Inherits UIElement
|
||||
|
||||
' Register an attached dependency property with the specified
|
||||
' property name, property type, owner type, and property metadata.
|
||||
|
||||
+13
-4
@@ -1,5 +1,5 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
|
||||
namespace CodeSampleCsharp
|
||||
{
|
||||
@@ -8,11 +8,20 @@ namespace CodeSampleCsharp
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow() => InitializeComponent();
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Test get/set accessors.
|
||||
Aquarium aquarium = new();
|
||||
Aquarium.SetHasFish(aquarium, true);
|
||||
bool hasFish = Aquarium.GetHasFish(aquarium);
|
||||
Debug.WriteLine($"Has fish: {hasFish}");
|
||||
}
|
||||
}
|
||||
|
||||
//<RegisterAttachedProperty>
|
||||
public class Aquarium : DependencyObject
|
||||
public class Aquarium : UIElement
|
||||
{
|
||||
// Register an attached dependency property with the specified
|
||||
// property name, property type, owner type, and property metadata.
|
||||
|
||||
+8
-2
@@ -8,13 +8,19 @@
|
||||
|
||||
Public Sub New()
|
||||
InitializeComponent()
|
||||
|
||||
' Test get/set accessors.
|
||||
Dim aquarium As New Aquarium()
|
||||
Aquarium.SetHasFish(aquarium, True)
|
||||
Dim hasFish As Boolean = Aquarium.GetHasFish(aquarium)
|
||||
Debug.WriteLine($"Has fish: {hasFish}")
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
'<RegisterAttachedProperty>
|
||||
Public Class Aquarium
|
||||
Inherits DependencyObject
|
||||
Public Class Aquarium
|
||||
Inherits UIElement
|
||||
|
||||
' Register an attached dependency property with the specified
|
||||
' property name, property type, owner type, and property metadata.
|
||||
|
||||
Reference in New Issue
Block a user