diff --git a/dotnet-desktop-guide/net/wpf/data/index.md b/dotnet-desktop-guide/net/wpf/data/index.md index 3bd5e3e9c5..f97e8a1c6c 100644 --- a/dotnet-desktop-guide/net/wpf/data/index.md +++ b/dotnet-desktop-guide/net/wpf/data/index.md @@ -81,7 +81,12 @@ This figure illustrates the different types of data flow: - binding causes changes to the source property to automatically update the target property, but changes to the target property are not propagated back to the source property. This type of binding is appropriate if the control being bound is implicitly read-only. For instance, you may bind to a source such as a stock ticker, or perhaps your target property has no control interface provided for making changes, such as a data-bound background color of a table. If there's no need to monitor the changes of the target property, using the binding mode avoids the overhead of the binding mode. -- binding causes changes to either the source property or the target property to automatically update the other. This type of binding is appropriate for editable forms or other fully interactive UI scenarios. Most properties default to binding, but some dependency properties (typically properties of user-editable controls such as the and [CheckBox.IsChecked](xref:System.Windows.Controls.Primitives.ToggleButton.IsChecked) default to binding. A programmatic way to determine whether a dependency property binds one-way or two-way by default is to get the property metadata with and then check the Boolean value of the property. +- binding causes changes to either the source property or the target property to automatically update the other. This type of binding is appropriate for editable forms or other fully interactive UI scenarios. Most properties default to binding, but some dependency properties (typically properties of user-editable controls such as the and [CheckBox.IsChecked](xref:System.Windows.Controls.Primitives.ToggleButton.IsChecked) default to binding. + + A programmatic way to determine whether a dependency property binds one-way or two-way by default is to get the property metadata with . The return type of this method is , which doesn't contain any metadata about binding. However, if this type can be cast to the derived , then the Boolean value of the property can be checked. The following code example demonstrates getting the metadata for the property: + + :::code language="csharp" source="./snippets/index/csharp/Metadata.cs" id="print_metadata"::: + :::code language="vb" source="./snippets/index/vb/Metadata.vb" id="print_metadata"::: - is the reverse of binding; it updates the source property when the target property changes. One example scenario is if you only need to reevaluate the source value from the UI. @@ -149,7 +154,7 @@ Binding sources are tied to the active property on a parent element is useful when you're binding multiple properties to the same source. However, sometimes it may be more appropriate to specify the binding source on individual binding declarations. For the previous example, instead of using the property, you can specify the binding source by setting the property directly on the binding declaration of the button, as in the following example. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/AutoConvertPropertyToColor.xaml" id="BindAutoConvertColorCompactBinding"::: +:::code language="xaml" source="./snippets/index/csharp/AutoConvertPropertyToColor.xaml" id="BindAutoConvertColorCompactBinding"::: Other than setting the property on an element directly, inheriting the value from an ancestor (such as the button in the first example), and explicitly specifying the binding source by setting the property on the binding (such as the button the last example), you can also use the property or the property to specify the binding source. The property is useful when you're binding to other elements in your app, such as when you're using a slider to adjust the width of a button. The property is useful when the binding is specified in a or a . For more information, see [Binding sources overview](binding-sources-overview.md). @@ -177,7 +182,7 @@ For more information, see the and to the value to use is one of the four necessary components of a binding, in the scenarios that you want to bind to an entire object, the value to use would be the same as the binding source object. In those cases, it's applicable to not specify a . Consider the following example. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/EmptyBinding.xaml" id="EmptyBinding"::: +:::code language="xaml" source="./snippets/index/csharp/EmptyBinding.xaml" id="EmptyBinding"::: The above example uses the empty binding syntax: {Binding}. In this case, the inherits the DataContext from a parent DockPanel element (not shown in this example). When the path isn't specified, the default is to bind to the entire object. In other words, in this example, the path has been left out because we are binding the property to the entire object. (See the [Binding to collections](#binding-to-collections) section for an in-depth discussion.) @@ -191,8 +196,8 @@ Before getting into other features and usages of data binding, it's useful to in Consider the following example, where `myDataObject` is an instance of the `MyData` class, `myBinding` is the source object, and `MyData` is a defined class that contains a string property named `ColorName`. This example binds the text content of `myText`, an instance of , to `ColorName`. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/ManualBinding.cs" id="CodeOnlyBinding"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/ManualBinding.vb" id="CodeOnlyBinding"::: +:::code language="csharp" source="./snippets/index/csharp/ManualBinding.cs" id="CodeOnlyBinding"::: +:::code language="vb" source="./snippets/index/vb/ManualBinding.vb" id="CodeOnlyBinding"::: You can use the same *myBinding* object to create other bindings. For example, you can use the *myBinding* object to bind the text content of a check box to *ColorName*. In that scenario, there will be two instances of sharing the *myBinding* object. @@ -211,8 +216,8 @@ Adding this information to the figure in the [Create a binding](#create-a-bindin However, what if instead of having a property of type string your binding source object has a *Color* property of type ? In that case, in order for the binding to work you would need to first turn the *Color* property value into something that the property accepts. You would need to create a custom converter by implementing the interface, as in the following example. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/ColorBrushConverter.cs" id="ColorBrushConverter"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/ColorBrushConverter.vb" id="ColorBrushConverter"::: +:::code language="csharp" source="./snippets/index/csharp/ColorBrushConverter.cs" id="ColorBrushConverter"::: +:::code language="vb" source="./snippets/index/vb/ColorBrushConverter.vb" id="ColorBrushConverter"::: See for more information. @@ -264,11 +269,11 @@ Because views do not change the underlying source collections, each source colle One way to create and use a view is to instantiate the view object directly and then use it as the binding source. For example, consider the [Data binding demo][data-binding-demo] app shown in the [What is data binding](#what-is-data-binding) section. The app is implemented such that the binds to a view over the data collection instead of the data collection directly. The following example is extracted from the [Data binding demo][data-binding-demo] app. The class is the XAML proxy of a class that inherits from . In this particular example, the of the view is bound to the *AuctionItems* collection (of type ) of the current app object. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/CollectionView.xaml" id="CollectionView"::: +:::code language="xaml" source="./snippets/index/csharp/CollectionView.xaml" id="CollectionView"::: The resource *listingDataView* then serves as the binding source for elements in the app, such as the . -:::code language="xaml" source="./snippets/data-binding-overview/csharp/CollectionView.xaml" id="ListBoxCollectionView"::: +:::code language="xaml" source="./snippets/index/csharp/CollectionView.xaml" id="ListBoxCollectionView"::: To create another view for the same collection, you can create another instance and give it a different `x:Key` name. @@ -296,20 +301,20 @@ As mentioned before, views can apply a sort order to a collection. As it exists The following example shows the sorting logic of the "Sort by category and date" of the app UI in the [What is data binding](#what-is-data-binding) section. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/CollectionView.xaml.cs" id="AddSortChecked"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/CollectionView.xaml.vb" id="AddSortChecked"::: +:::code language="csharp" source="./snippets/index/csharp/CollectionView.xaml.cs" id="AddSortChecked"::: +:::code language="vb" source="./snippets/index/vb/CollectionView.xaml.vb" id="AddSortChecked"::: #### Filtering Views can also apply a filter to a collection, so that the view shows only a certain subset of the full collection. You might filter on a condition in the data. For instance, as is done by the app in the [What is data binding](#what-is-data-binding) section, the "Show only bargains" contains logic to filter out items that cost $25 or more. The following code is executed to set *ShowOnlyBargainsFilter* as the event handler when that is selected. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/CollectionView.xaml.cs" id="ListingViewFilter"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/CollectionView.xaml.vb" id="ListingViewFilter"::: +:::code language="csharp" source="./snippets/index/csharp/CollectionView.xaml.cs" id="ListingViewFilter"::: +:::code language="vb" source="./snippets/index/vb/CollectionView.xaml.vb" id="ListingViewFilter"::: The *ShowOnlyBargainsFilter* event handler has the following implementation. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/CollectionView.xaml.cs" id="FilterEvent"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/CollectionView.xaml.vb" id="FilterEvent"::: +:::code language="csharp" source="./snippets/index/csharp/CollectionView.xaml.cs" id="FilterEvent"::: +:::code language="vb" source="./snippets/index/vb/CollectionView.xaml.vb" id="FilterEvent"::: If you're using one of the classes directly instead of , you would use the property to specify a callback. For an example, see [Filter Data in a View (.NET Framework)](../../../framework/wpf/data/how-to-filter-data-in-a-view.md). @@ -319,8 +324,8 @@ Except for the internal class that views an . -:::code language="csharp" source="./snippets/data-binding-overview/csharp/CollectionView.xaml.cs" id="ListingGroupCheck"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/CollectionView.xaml.vb" id="ListingGroupCheck"::: +:::code language="csharp" source="./snippets/index/csharp/CollectionView.xaml.cs" id="ListingGroupCheck"::: +:::code language="vb" source="./snippets/index/vb/CollectionView.xaml.vb" id="ListingGroupCheck"::: For another grouping example, see [Group Items in a ListView That Implements a GridView (.NET Framework)](../../../framework/wpf/controls/how-to-group-items-in-a-listview-that-implements-a-gridview.md). @@ -350,7 +355,7 @@ The notion of a current item is useful not only for navigation of items in a col You can implement the master-detail scenario simply by having two or more controls bound to the same view. The following example from the [Data binding demo][data-binding-demo] shows the markup of the and the you see on the app UI in the [What is data binding](#what-is-data-binding) section. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/CollectionView.xaml" id="ListBoxContentControl"::: +:::code language="xaml" source="./snippets/index/csharp/CollectionView.xaml" id="ListBoxContentControl"::: Notice that both of the controls are bound to the same source, the *listingDataView* static resource (see the definition of this resource in the [How to create a view section](#how-to-create-a-view)). This binding works because when a singleton object (the in this case) is bound to a collection view, it automatically binds to the of the view. The objects automatically synchronize currency and selection. If your list control isn't bound to a object as in this example, then you would need to set its property to `true` for this to work. @@ -368,7 +373,7 @@ As shown in the example in the previous section, both the . As shown in the example in the previous section, the explicitly uses the *detailsProductListingTemplate* data template. The control implicitly uses the following data template when displaying the *AuctionItem* objects in the collection. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/CollectionView.xaml" id="AuctionItemDataTemplate"::: +:::code language="xaml" source="./snippets/index/csharp/CollectionView.xaml" id="AuctionItemDataTemplate"::: With the use of those two DataTemplates, the resulting UI is the one shown in the [What is data binding](#what-is-data-binding) section. As you can see from that screenshot, in addition to letting you place data in your controls, DataTemplates allow you to define compelling visuals for your data. For example, s are used in the above so that *AuctionItem*s with *SpecialFeatures* value of *HighLight* would be displayed with an orange border and a star. @@ -382,7 +387,7 @@ Most app that take user input need to have validation logic to ensure that the u The WPF data binding model allows you to associate with your object. For example, the following example binds a to a property named `StartPrice` and adds a object to the property. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/DataValidation.xaml" id="TextboxStartPrice"::: +:::code language="xaml" source="./snippets/index/csharp/DataValidation.xaml" id="TextboxStartPrice"::: A object checks whether the value of a property is valid. WPF has two types of built-in objects: @@ -392,12 +397,12 @@ A object checks whether the value You can also create your own validation rule by deriving from the class and implementing the method. The following example shows the rule used by the *Add Product Listing* "Start Date" from the [What is data binding](#what-is-data-binding) section. -:::code language="csharp" source="./snippets/data-binding-overview/csharp/FutureDateRule.cs" id="FutureDateRule"::: -:::code language="vb" source="./snippets/data-binding-overview/vb/FutureDateRule.vb" id="FutureDateRule"::: +:::code language="csharp" source="./snippets/index/csharp/FutureDateRule.cs" id="FutureDateRule"::: +:::code language="vb" source="./snippets/index/vb/FutureDateRule.vb" id="FutureDateRule"::: The *StartDateEntryForm* uses this *FutureDateRule*, as shown in the following example. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/DataValidation.xaml" id="TextboxStartDate"::: +:::code language="xaml" source="./snippets/index/csharp/DataValidation.xaml" id="TextboxStartDate"::: Because the value is , the binding engine updates the source value on every keystroke, which means it also checks every rule in the collection on every keystroke. We discuss this further in the Validation Process section. @@ -405,13 +410,13 @@ Because the value is < If the user enters an invalid value, you may want to provide some feedback about the error on the app UI. One way to provide such feedback is to set the attached property to a custom . As shown in the previous subsection, the *StartDateEntryForm* uses an called *validationTemplate*. The following example shows the definition of *validationTemplate*. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/DataValidation.xaml" id="ControlTemplate"::: +:::code language="xaml" source="./snippets/index/csharp/DataValidation.xaml" id="ControlTemplate"::: The element specifies where the control being adorned should be placed. In addition, you may also use a to display the error message. Both the *StartDateEntryForm* and the *StartPriceEntryForm*es use the style *textStyleTextBox*, which creates a that displays the error message. The following example shows the definition of *textStyleTextBox*. The attached property is `true` when one or more of the bindings on the properties of the bound element are in error. -:::code language="xaml" source="./snippets/data-binding-overview/csharp/DataValidation.xaml" id="TextBoxStyle"::: +:::code language="xaml" source="./snippets/index/csharp/DataValidation.xaml" id="TextBoxStyle"::: With the custom and the , the *StartDateEntryForm* looks like the following when there's a validation error. diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/App.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/App.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/App.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/App.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/App.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/App.xaml.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/App.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/App.xaml.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AuctionItem.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AuctionItem.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AuctionItem.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AuctionItem.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AutoConvertPropertyToColor.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AutoConvertPropertyToColor.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AutoConvertPropertyToColor.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AutoConvertPropertyToColor.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AutoConvertPropertyToColor.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AutoConvertPropertyToColor.xaml.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/AutoConvertPropertyToColor.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/AutoConvertPropertyToColor.xaml.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/CollectionView.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/CollectionView.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/CollectionView.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/CollectionView.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/CollectionView.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/CollectionView.xaml.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/CollectionView.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/CollectionView.xaml.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/ColorBrushConverter.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/ColorBrushConverter.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/ColorBrushConverter.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/ColorBrushConverter.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DataValidation.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DataValidation.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DataValidation.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DataValidation.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DataValidation.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DataValidation.xaml.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DataValidation.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DataValidation.xaml.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DateConverter.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DateConverter.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/DateConverter.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/DateConverter.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/EmptyBinding.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/EmptyBinding.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/EmptyBinding.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/EmptyBinding.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/EmptyBinding.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/EmptyBinding.xaml.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/EmptyBinding.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/EmptyBinding.xaml.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/FutureDateRule.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/FutureDateRule.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/FutureDateRule.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/FutureDateRule.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MainWindow.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MainWindow.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MainWindow.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MainWindow.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MainWindow.xaml.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MainWindow.xaml.cs similarity index 93% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MainWindow.xaml.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MainWindow.xaml.cs index 660283f372..4680e9f5c1 100644 --- a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MainWindow.xaml.cs +++ b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MainWindow.xaml.cs @@ -23,6 +23,7 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); + bindings.Metadata.PrintMetadata(); } } } diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/ManualBinding.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/ManualBinding.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/ManualBinding.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/ManualBinding.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/Metadata.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/Metadata.cs new file mode 100644 index 0000000000..3e782e4861 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/Metadata.cs @@ -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 + { + // + 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 + */ + } + // + } +} diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MyData.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MyData.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/MyData.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/MyData.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/SpecialFeatures.cs b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/SpecialFeatures.cs similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/SpecialFeatures.cs rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/SpecialFeatures.cs diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/bindings.csproj b/dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/csharp/bindings.csproj rename to dotnet-desktop-guide/net/wpf/data/snippets/index/csharp/bindings.csproj diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/Application.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Application.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/Application.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Application.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/Application.xaml.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Application.xaml.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/Application.xaml.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Application.xaml.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/AuctionItem.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/AuctionItem.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/AuctionItem.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/AuctionItem.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/CollectionView.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/CollectionView.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/CollectionView.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/CollectionView.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/CollectionView.xaml.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/CollectionView.xaml.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/CollectionView.xaml.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/CollectionView.xaml.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/ColorBrushConverter.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/ColorBrushConverter.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/ColorBrushConverter.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/ColorBrushConverter.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/FutureDateRule.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/FutureDateRule.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/FutureDateRule.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/FutureDateRule.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MainWindow.xaml b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MainWindow.xaml similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MainWindow.xaml rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MainWindow.xaml diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MainWindow.xaml.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MainWindow.xaml.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MainWindow.xaml.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MainWindow.xaml.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/ManualBinding.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/ManualBinding.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/ManualBinding.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/ManualBinding.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Metadata.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Metadata.vb new file mode 100644 index 0000000000..d80dafbc77 --- /dev/null +++ b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/Metadata.vb @@ -0,0 +1,34 @@ +Public Class 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 + ' + +End Class diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MyData.vb b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MyData.vb similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/MyData.vb rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/MyData.vb diff --git a/dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/bindings.vbproj b/dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj similarity index 100% rename from dotnet-desktop-guide/net/wpf/data/snippets/data-binding-overview/vb/bindings.vbproj rename to dotnet-desktop-guide/net/wpf/data/snippets/index/vb/bindings.vbproj