c# - Is there any semantical difference between element property syntax and atrribute property syntax? -
I thought that element properties syntax and property property syntax have no major vocabulary differences. However, I came to know that there should be some difference in it.
e.g. The following example shows just a simple trigger:
& lt; Page xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http: //schemas.microsoft.com/winfx/2006/xaml"> & Lt; Button & gt; & Lt; Button.Template & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Textblocks x: name = "hello" text = "hello" /> & Lt; ControlTemplate.Triggers & gt; & Lt; Trigger Property = "Ismouth Over" Value = "True" & gt; & Lt; Setter Property = "Foreground" value = "Red" TargetName = "Hello" /> & Lt; / Catalyst & gt; & Lt; /ControlTemplate.Triggers> & Lt; / ControlTemplate & gt; & Lt; /Button.Template> & Lt; / Button & gt; & Lt; / Page & gt; However, if I use an element property syntax for the property of the trigger property , then it is an upset that says setter! (Not triggering) requires both the property and the price.
& lt; Page xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http: //schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; Button & gt; & Lt; Button.Template & gt; & Lt; ControlTemplate TargetType = "{x: type button}" & gt; & Lt; Textblocks x: name = "hello" text = "hello" /> & Lt; ControlTemplate.Triggers & gt; & Lt; Trigger value = "true" & gt; & Lt; Trigger.Property & gt; IsMouseOver & LT; /Trigger.Property> & Lt; Setter Property = "Foreground" value = "Red" TargetName = "Hello" /> & Lt; / Catalyst & gt; & Lt; /ControlTemplate.Triggers> & Lt; / ControlTemplate & gt; & Lt; /Button.Template> & Lt; / Button & gt; & Lt; / Page & gt; So, what is the difference between element properties syntax and attribute properties syntax in hidden ?
There should be no differences I think you just got a bug in the XML parser.
There is special handling for the setter, trigger, and condition of the structure. Check out with the reflector, which overrides the handling of asset-sets for value and property properties. I think it is so that the property could parse the value property based on property in a different way. For example, it parses "red" as a brush instead of a brush when the property sees the foreground and the foreground type is of the brush.
It seems that the hook overrides all sets of assets named Value or Property within a set, but this element does not keep the property syntax properly, to see the effect, such a markup Try creating an extension:
Public class test: Markup Extension {Receive {Public Dependency Property Property}; Set; } Public reliance Property Properties 2 {Received; Set; } Public override object ProvideValue (IServiceProvider serviceProvider) {return property ?? Property2; }} The following XAML will get an error similar to your second example, and you can verify by setting a breakpoint that the property is never set up:
< Code> & lt; Trigger.Property & gt; & Lt; Local: Test & gt; & Lt; Local: Test.Property & gt; IsMouseOver & lt; / Local: Test.Property & gt; & Lt; / Local: Test & gt; & Lt; /Trigger.Property>
However, this will work, because the property name is not "property":
& lt; Trigger.Property & gt; & Lt; Local: Test & gt; & Lt; Local: Test.Property2 & gt; IsMouseOver & lt; / Local: Test.Property2 & gt; & Lt; / Local: Test & gt; & Lt; /Trigger.Property> And this will work, because this attribute uses syntax:
& Lt; /Trigger.Property> If you really need to use element properties syntax, which will give you an alternative solution: Create a markup extension that includes a type of property dependency property whose name includes "property" Something else, and it is back in ProvideValue
Comments
Post a Comment