Files
docs-desktop/dotnet-desktop-guide/net/wpf/properties/snippets/dependency-properties-overview/csharp/MainWindow.xaml.cs
T
Tris ShoresandAndy De George 57b6ca1593 Content update - Dependency properties overview (user story 1878471) (#1160)
* Update article and code projects

* Further edits

* Fix links

* Relocate article & snippets to wpf/properties folder

* add toc and redirects

* Add acrolinx comment and make a minor edit.

* minor

Co-authored-by: Andy De George (adegeo) <[email protected]>
2021-09-27 13:53:44 -07:00

49 lines
1.3 KiB
C#

using System.Windows;
using System.Windows.Controls;
namespace CodeSampleCsharp
{
/// <summary>
/// Interaction logic for MainWindow.xaml.
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// <ProceduralPropertySet>
Button myButton = new();
myButton.Width = 200.0;
// </ProceduralPropertySet>
// <ProceduralPropertyGet>
double whatWidth = myButton.Width;
// </ProceduralPropertyGet>
}
// <DefineDependencyProperty>
public static readonly DependencyProperty IsSpinningProperty = DependencyProperty.Register(
"IsSpinning", typeof(bool),
typeof(MainWindow)
);
public bool IsSpinning
{
get => (bool)GetValue(IsSpinningProperty);
set => SetValue(IsSpinningProperty, value);
}
// </DefineDependencyProperty>
}
// <OverrideMetadata>
public class SpinnerControl : ItemsControl
{
static SpinnerControl() => DefaultStyleKeyProperty.OverrideMetadata(
typeof(SpinnerControl),
new FrameworkPropertyMetadata(typeof(SpinnerControl))
);
}
// </OverrideMetadata>
}