How to initialise dictionary from variable?

Having a bit of a mind blank around this.

I have an argument on a xaml which I’d like to change from this

New Dictionary(of String,String) from {{“Key1”,“Value1”},{“Key2”},{“Value2”}}

to…

myDictionary = New Dictionary(of String,String) from in_myVariable
in_myVariable = {{“Key1”,“Value1”},{“Key2”},{“Value2”}}

so that the key value pairs are a bit easier to read and manage as an argument going into the xaml… without all the dictionary prefix stuff… seems simple but I’m having trouble remembering how to do this.

@Jon_G

myDictionary = New Dictionary(Of String, String) From {{"Key1", "Value1"}, {"Key2", "Value2"}}
in_myVariable = myDictionary

Create an In argument in your XAML file, say in_myVariable, of type Dictionary(Of String, String).

Hi @Jon_G

Follow the below steps:

=> Create a Dictionary Variable:

  • Name: myDictionary
  • DataType: System.Collections.Generic.Dictionary(System.String, System.String)

=> Use the below syntax in Assign in Main.xaml:

myDictionary = New Dictionary(Of String, String) From {{"Key1", "Value1"}, {"Key2", "Value2"}}

=> Create a new sequence file and give a name YourXamlFile

=> Create an In Argument in_myVariable of DataType System.Collections.Generic.Dictionary(System.String, System.String)

=> In Main.xaml drag and drop the newly created YourXamlFile.xaml and click on Import Arguments. Open the Arguments and map in_myVariable with myDictionary

Below is the sample zip file illustrating the above process.

BlankProcess3.zip (359.0 KB)

Regards

I believe what you want is not possible. You could instead use a loop to iterate through the collection and add the keys and values to the dictionary.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.