home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 2
Skins and Design
Skinning contest: One month to go
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Albert" data-source="post: 680608" data-attributes="member: 67886"><p><strong>AW: Skinning contest: One month to go</strong></p><p></p><p>Hehe FreakJ, here you're crossing the border to the really complicated MPF elements.</p><p></p><p>Although <em>ResourceWrapper</em> is quite easy, the others aren't.</p><p></p><p><span style="font-size: 18px">ResourceWrapper</span></p><p></p><p><em>ResourceWrapper</em> is - as its name says - simply a wrapper for other elements. It is useful in ResourceDictionaries:</p><p></p><p>[CODE]</p><p><SomeUIElement></p><p> <Resources></p><p> <ResourceWrapper x:Key="BlackColor" Resource="#FF000000"/></p><p> </Resources></p><p></SomeUIElement></p><p>[/CODE]</p><p></p><p>Every element/resource/whatever can be wrapped in a ResourceWrapper but it is only really needed for elements which don't have an XML element representation. For example, there is no "constructor" element for a simple string. That means, you cannot write <String>HelloWorld</String>, because there is no <String> element. The same with color values like in the example above. The ResourceWrapper can be used to make such elements available in resource dictionaries.</p><p></p><p><span style="font-size: 18px">LateBoundValue</span></p><p></p><p>To understand why <em>LateBoundValue</em> is needed, you need to know how the XAML engine processes the files, which is not so easy. When the engine uses a resource provided by a ResourceWrapper, that resource is extracted from the wrapper instance at once. For example if you have a property assignment <em>SomeColor="{StaticResource BlackColor}"</em>, the BlackColor resource from above (the string "#FF000000") will be used rather than the enclosing ResourceWrapper. Then, the string is converted into a Color object and assigned to the SomeColor property.</p><p></p><p>But when using bindings, you sometimes don't want that the value is extracted at once.</p><p>Here comes an example. In fact that is the common usage scenario for LateBoundValues:</p><p></p><p>Think of a <Command>, maybe a command of a Button:</p><p>(the following code will not work)</p><p>[CODE]</p><p><Button></p><p> <Button.Command></p><p> <Command></p><p> <Command.Parameters></p><p> <Binding Source="..." Path="..."/></p><p> </Command.Parameters></p><p> </Command></p><p> </Button.Command></p><p></Button></p><p>[/CODE]</p><p></p><p>Internally, the Parameters property of the command is just a collection, so the XAML parser has no chance to bind the given Binding to some property. So the parser needs to evaluate the binding at once, which will probably fail, and thus you only get a null value as parameter.</p><p></p><p>To solve that problem, we have LateBoundValue:</p><p>(works well)</p><p>[CODE]</p><p><Button></p><p> <Button.Command></p><p> <Command></p><p> <Command.Parameters></p><p> <LateBoundValue></p><p> <Binding Source="..." Path="..."/></p><p> </LateBoundValue></p><p> </Command.Parameters></p><p> </Command></p><p> </Button.Command></p><p></Button></p><p>[/CODE]</p><p></p><p>Here, the XAML parser can bind the binding to the Value property of the LateBoundValue instance. When the command is executed, it explicitly converts all parameters of type LateBoundValue to their contained Value resource.</p><p></p><p><span style="font-size: 18px">BindingWrapper</span></p><p></p><p>The last class you mentioned is BindingWrapper. I won't describe it here completely because you'll only use it if you are a "master of MPF". Like ResourceWrappers, which are used to pass resources to DynamicMarkupExtensions, BindingWrappers are needed to pass custom binding instances to PickupBinding markup extensions. You can see that in the <em>DefaultSingleMarkableTreeItemContainerStyle</em>, defined in <em>OtherControls.xaml</em>.</p><p></p><p>I hope I could make things clearer. Please ask if you still have questions.</p></blockquote><p></p>
[QUOTE="Albert, post: 680608, member: 67886"] [b]AW: Skinning contest: One month to go[/b] Hehe FreakJ, here you're crossing the border to the really complicated MPF elements. Although [I]ResourceWrapper[/I] is quite easy, the others aren't. [SIZE="5"]ResourceWrapper[/SIZE] [I]ResourceWrapper[/I] is - as its name says - simply a wrapper for other elements. It is useful in ResourceDictionaries: [CODE] <SomeUIElement> <Resources> <ResourceWrapper x:Key="BlackColor" Resource="#FF000000"/> </Resources> </SomeUIElement> [/CODE] Every element/resource/whatever can be wrapped in a ResourceWrapper but it is only really needed for elements which don't have an XML element representation. For example, there is no "constructor" element for a simple string. That means, you cannot write <String>HelloWorld</String>, because there is no <String> element. The same with color values like in the example above. The ResourceWrapper can be used to make such elements available in resource dictionaries. [SIZE="5"]LateBoundValue[/SIZE] To understand why [I]LateBoundValue[/I] is needed, you need to know how the XAML engine processes the files, which is not so easy. When the engine uses a resource provided by a ResourceWrapper, that resource is extracted from the wrapper instance at once. For example if you have a property assignment [I]SomeColor="{StaticResource BlackColor}"[/I], the BlackColor resource from above (the string "#FF000000") will be used rather than the enclosing ResourceWrapper. Then, the string is converted into a Color object and assigned to the SomeColor property. But when using bindings, you sometimes don't want that the value is extracted at once. Here comes an example. In fact that is the common usage scenario for LateBoundValues: Think of a <Command>, maybe a command of a Button: (the following code will not work) [CODE] <Button> <Button.Command> <Command> <Command.Parameters> <Binding Source="..." Path="..."/> </Command.Parameters> </Command> </Button.Command> </Button> [/CODE] Internally, the Parameters property of the command is just a collection, so the XAML parser has no chance to bind the given Binding to some property. So the parser needs to evaluate the binding at once, which will probably fail, and thus you only get a null value as parameter. To solve that problem, we have LateBoundValue: (works well) [CODE] <Button> <Button.Command> <Command> <Command.Parameters> <LateBoundValue> <Binding Source="..." Path="..."/> </LateBoundValue> </Command.Parameters> </Command> </Button.Command> </Button> [/CODE] Here, the XAML parser can bind the binding to the Value property of the LateBoundValue instance. When the command is executed, it explicitly converts all parameters of type LateBoundValue to their contained Value resource. [SIZE="5"]BindingWrapper[/SIZE] The last class you mentioned is BindingWrapper. I won't describe it here completely because you'll only use it if you are a "master of MPF". Like ResourceWrappers, which are used to pass resources to DynamicMarkupExtensions, BindingWrappers are needed to pass custom binding instances to PickupBinding markup extensions. You can see that in the [I]DefaultSingleMarkableTreeItemContainerStyle[/I], defined in [I]OtherControls.xaml[/I]. I hope I could make things clearer. Please ask if you still have questions. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 2
Skins and Design
Skinning contest: One month to go
Contact us
RSS
Top
Bottom