-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify WPF metadata return type (#1694)
* move code to right folder; add snippet * Clarify metadata type
- Loading branch information
Showing
35 changed files
with
111 additions
and
26 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/Metadata.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,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.Intrinsics.Arm; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace bindings | ||
{ | ||
class Metadata | ||
{ | ||
//<print_metadata> | ||
public static void PrintMetadata() | ||
{ | ||
// Get the metadata for the property | ||
PropertyMetadata metadata = TextBox.TextProperty.GetMetadata(typeof(TextBox)); | ||
|
||
// Check if metadata type is FrameworkPropertyMetadata | ||
if (metadata is FrameworkPropertyMetadata frameworkMetadata) | ||
{ | ||
System.Diagnostics.Debug.WriteLine($"TextBox.Text property metadata:"); | ||
System.Diagnostics.Debug.WriteLine($" BindsTwoWayByDefault: {frameworkMetadata.BindsTwoWayByDefault}"); | ||
System.Diagnostics.Debug.WriteLine($" IsDataBindingAllowed: {frameworkMetadata.IsDataBindingAllowed}"); | ||
System.Diagnostics.Debug.WriteLine($" AffectsArrange: {frameworkMetadata.AffectsArrange}"); | ||
System.Diagnostics.Debug.WriteLine($" AffectsMeasure: {frameworkMetadata.AffectsMeasure}"); | ||
System.Diagnostics.Debug.WriteLine($" AffectsRender: {frameworkMetadata.AffectsRender}"); | ||
System.Diagnostics.Debug.WriteLine($" Inherits: {frameworkMetadata.Inherits}"); | ||
} | ||
|
||
/* Displays: | ||
* | ||
* TextBox.Text property metadata: | ||
* BindsTwoWayByDefault: True | ||
* IsDataBindingAllowed: True | ||
* AffectsArrange: False | ||
* AffectsMeasure: False | ||
* AffectsRender: False | ||
* Inherits: False | ||
*/ | ||
} | ||
//</print_metadata> | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions
34
dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Metadata.vb
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,34 @@ | ||
Public Class Metadata | ||
|
||
'<print_metadata> | ||
Public Shared Sub PrintMetadata() | ||
|
||
Dim metadata As PropertyMetadata = TextBox.TextProperty.GetMetadata(GetType(TextBox)) | ||
Dim frameworkMetadata As FrameworkPropertyMetadata = TryCast(metadata, FrameworkPropertyMetadata) | ||
|
||
If frameworkMetadata IsNot Nothing Then | ||
|
||
System.Diagnostics.Debug.WriteLine($"TextBox.Text property metadata:") | ||
System.Diagnostics.Debug.WriteLine($" BindsTwoWayByDefault: {frameworkMetadata.BindsTwoWayByDefault}") | ||
System.Diagnostics.Debug.WriteLine($" IsDataBindingAllowed: {frameworkMetadata.IsDataBindingAllowed}") | ||
System.Diagnostics.Debug.WriteLine($" AffectsArrange: {frameworkMetadata.AffectsArrange}") | ||
System.Diagnostics.Debug.WriteLine($" AffectsMeasure: {frameworkMetadata.AffectsMeasure}") | ||
System.Diagnostics.Debug.WriteLine($" AffectsRender: {frameworkMetadata.AffectsRender}") | ||
System.Diagnostics.Debug.WriteLine($" Inherits: {frameworkMetadata.Inherits}") | ||
|
||
' Displays: | ||
' | ||
' TextBox.Text property metadata: | ||
' BindsTwoWayByDefault: True | ||
' IsDataBindingAllowed: True | ||
' AffectsArrange: False | ||
' AffectsMeasure: False | ||
' AffectsRender: False | ||
' Inherits: False | ||
End If | ||
|
||
|
||
End Sub | ||
'</print_metadata> | ||
|
||
End Class |
File renamed without changes.
File renamed without changes.