I want to apply a new property (named "menufigure") for the pivot element, in order the color of the pivot item Change Header via a Defined ControlTemplate
That's why I created a new category for custom property, #include the required code-in the xaml.h file and included a new namespace ("xamlns: cap") defining custom assets According to the namespace.
PivotProperties.h
#pragma is once using the namespace Windows :: UI :: Xaml; Namespace Custom Attachment Properties {Public Reef Class PivotProperties Sealed: Windows :: UI :: XML :: DependencyObject {Public: Fixed Windows :: UI :: Color GetMenuForeground (UIElement ^ obj); Fixed Zero SetMenuForeground (UIElement ^ obj, Windows :: UI :: Color value); Static Property Dependency Property ^ MenuForldproperty {Dependency Property ^ Mill () {Return _ManuForFrintProperty; }} Personal: Fixed Dependency Property ^ _menuForegroundProperty; }; }
PivotProperties.cpp
#include "pch.h" # include "PivotProperties.h" namespace custom attachment prototypes; DependencyProperty ^ PivotProperties :: _ menuForegroundProperty = DependencyProperty :: Register Attached ("MenuAforg", Windows :: UI :: Color :: TypeID, Windows :: UI :: XML :: Controll :: Pivot :: Typied, Refused New Property Metatata ( Falls);) Windows :: UI :: Color PowoteProperty :: GetMenuForeground (UIElement ^ obj) {Return (Windows :: UI :: Color) obj- & gt; GetValue (_menuForegroundProperty); } Zero PivotProperties :: SetMenuForeground (UIElement ^ obj, Windows :: UI :: Color value) {obj- & gt; SetValue (_menuForegroundProperty, value); }
To use a new property for a pivot element, I declared a new xml name in the original element like the following element
& Lt; Page / / ... ... xmlns: cap = "clr-namespace: custom attachproperties" & gt;
But if I try to use the new property ...
& pivot x: name = "pivot" cap: PivotProperties.MenuForeground = "Red" & gt; ... & lt; / Axis & gt;
... an error occurs, saying: "The attachment property was not found in the 'MenuForeground' type 'PivotProperties'.
How to fix it?
The third parameter of the method should be ownerType
The type of owner who is entering the dependency property
is not the type of object where you want to set the asset.
Then your declaration should appear Like this:
Dependency Props PtProperties :: _MenuFrintipi = Dependency Property :: Register Attached ("MenuForGround", Windows :: UI :: Color :: Typied, PivotProperties :: Typied, // Here Reef New Property Matadata (False));
Please also keep in mind that your PivotProperties
goes from class DependencyObject
, as long as it declares only the attached asset.
You may also consi have other properties such as Background
and Aug While Rbhumi > Windows.UI.Xaml.Media.Brush
using afraid to use.
No comments:
Post a Comment