Jump to: navigation, search

Difference between revisions of "KeyValueList"


(Created page with "{{XAMLControlInfoBox | title = {{PAGENAME}} | name = {{PAGENAME}} | namespace= UBIK.WinX.Controls | image = [[File:SY_{{PAGENAME}}.png|220px]] | imagecaption = imagecaption |...")
 
 
(3 intermediate revisions by 3 users not shown)
Line 14: Line 14:
  
 
=== Example ===
 
=== Example ===
The following example shows how to use the control with two parameters in conjunction with the NavigateToGuidCommand. The first parameter specifies the Guid of the target document and the second parameter specifies the HotSpot that should be highlighted on that very document
+
The following example shows how to use the control with two parameters in conjunction with the NavigateToGuidCommand. The first parameter specifies the Guid of the target document and the second parameter specifies the HotSpot that should be highlighted on that very document. This example needs a namespace declaration '''xmlns:ctrls="using:UBIK.WinX.Controls"'''
 
<source lang = "xml">
 
<source lang = "xml">
 
     <Button Command="{Binding NavigateToGuidCommand}" Content="Test">
 
     <Button Command="{Binding NavigateToGuidCommand}" Content="Test">
Line 20: Line 20:
 
             <ctrls:KeyValueList>
 
             <ctrls:KeyValueList>
 
                 <ctrls:KeyValueParameter Key="Guid" Value="c9ad0e93-395a-4b4e-a526-fb5d5e42f8ff" />
 
                 <ctrls:KeyValueParameter Key="Guid" Value="c9ad0e93-395a-4b4e-a526-fb5d5e42f8ff" />
                 <ctrls:KeyValueParameter Key="HotSpot" Value="05d2e931-ad11-4407-a8e6-337f6779f96b" />
+
                 <ctrls:KeyValueParameter Key="HotSpot" Value="b9e855f9-d3be-4b60-b4e3-19398f5925b5" />
 
             </ctrls:KeyValueList>
 
             </ctrls:KeyValueList>
 
         </Button.CommandParameter>
 
         </Button.CommandParameter>
 
     </Button>
 
     </Button>
 
</source>
 
</source>
 +
 +
To use a Binding in the KeyValueParameter, the following logic has to be used, instead of applying the binding directly on the Value property
 +
 +
<source lang = "xml">
 +
    <Button Content="{Binding Header}" Command="{Binding CreateChildItemCommand}" x:Name="CreateButton" Tag="{Binding}">
 +
        <Button.CommandParameter>
 +
            <uc:KeyValueList>
 +
                <uc:KeyValueParameter Key="Parent" Value="{Binding Tag, ElementName=CreateButton}"/>
 +
                <uc:KeyValueParameter Key="Type" Value="21fc990a-d064-4bee-8d48-3293351f827a"/>
 +
            </uc:KeyValueList>
 +
        </Button.CommandParameter>
 +
    </Button>
 +
</source>
 +
 +
  
 
== Parameters ==
 
== Parameters ==
Line 31: Line 46:
 
==See also==
 
==See also==
 
* [[XAML]]
 
* [[XAML]]
 +
 +
[[Category:Pages with broken file links|KeyValueList]]

Latest revision as of 08:39, 29 March 2022

KeyValueList
220px
imagecaption
Name KeyValueList
Namespace UBIK.WinX.Controls
Purpose Define a complex parameter type in XAML
Version 3.5+

Usage

The KeyValueList controls allows to declare a complex parameter type from within XAML markup. It can hold any number of KeyValueParameter elements, where each consists of a string Key and and associated value.


Example

The following example shows how to use the control with two parameters in conjunction with the NavigateToGuidCommand. The first parameter specifies the Guid of the target document and the second parameter specifies the HotSpot that should be highlighted on that very document. This example needs a namespace declaration xmlns:ctrls="using:UBIK.WinX.Controls"

    <Button Command="{Binding NavigateToGuidCommand}" Content="Test">
        <Button.CommandParameter>
            <ctrls:KeyValueList>
                <ctrls:KeyValueParameter Key="Guid" Value="c9ad0e93-395a-4b4e-a526-fb5d5e42f8ff" />
                <ctrls:KeyValueParameter Key="HotSpot" Value="b9e855f9-d3be-4b60-b4e3-19398f5925b5" />
            </ctrls:KeyValueList>
        </Button.CommandParameter>
    </Button>

To use a Binding in the KeyValueParameter, the following logic has to be used, instead of applying the binding directly on the Value property

    <Button Content="{Binding Header}" Command="{Binding CreateChildItemCommand}" x:Name="CreateButton" Tag="{Binding}">
        <Button.CommandParameter>
            <uc:KeyValueList>
                <uc:KeyValueParameter Key="Parent" Value="{Binding Tag, ElementName=CreateButton}"/>
                <uc:KeyValueParameter Key="Type" Value="21fc990a-d064-4bee-8d48-3293351f827a"/>
            </uc:KeyValueList>
        </Button.CommandParameter>
    </Button>


Parameters

KeyValueParameter can be added as child objects to an KeyValueList control. Each parameter object needs a unique Key and a Value, where the latter can be either a constant or dynamic value supplied through a binding.

See also