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

Clarify WPF metadata return type #1694

Merged
merged 2 commits into from
Sep 1, 2023
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
57 changes: 31 additions & 26 deletions dotnet-desktop-guide/net/wpf/data/index.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();
bindings.Metadata.PrintMetadata();
}
}
}
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>
}
}
34 changes: 34 additions & 0 deletions dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Metadata.vb
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
Loading