ConverterParameter — Any way to pass in some delimited list?


Basically, if I have:

<pre class="lang-xml prettyprint-override"><TextBlock Text="{Binding MyValue, Converter={StaticResource TransformedTextConverter}, ConverterParameter=?}" />

How would you go about passing in some type of array of items as the ConverterParameter. I figured I could pass in some type of delimited list, but I'm not sure what type of delimiter to use, or if there is a built-in way to pass in an array of parameters?


The ConverterParameter is of type object that means when the XAML is parsed there will not be any implicit conversion, if you pass in any delimited list it will just be interpreted as a string. You could of course split that in the convert method itself.

But as you probably want more complex objects you can do two things when dealing with static values: Create the object array as resource and reference it or create the array in place using element syntax, e.g.


<pre class="lang-xml prettyprint-override"><Window.Resources> <x:Array x:Key="params" Type="{x:Type ns:YourTypeHere}"> <ns:YourTypeHere /> <ns:YourTypeHere /> </x:Array> </Window.Resources> ... ConverterParameter={StaticResource params}


<pre class="lang-xml prettyprint-override"><TextBlock> <TextBlock.Text> <Binding Path="MyValue" Converter="{StaticResource TransformedTextConverter}"> <Binding.ConverterParameter> <x:Array Type="{x:Type ns:YourTypeHere}"> <ns:YourTypeHere /> <ns:YourTypeHere /> </x:Array> </Binding.ConverterParameter> </Binding> </TextBlock.Text> </TextBlock>


ConverterParameter is not a dependency property, so cannot be based on a binding

You could hardcode a value, such as an x-delimited list of parameters which you .Split(x) in your Converter, or you can use a MultiConverter which allows you to send multiple bound values to a Converter.

<pre class="lang-xml prettyprint-override"><!-- Not sure the exact syntax, but I'm fairly sure you have to escape the commas --> <TextBlock Text="{Binding MyValue, Converter={StaticResource TransformedTextConverter}, ConverterParameter={};@,@|}" />


<pre class="lang-xml prettyprint-override"><TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource MyMultiConverter}"> <Binding Path="MyValue" /> <Binding Path="Parameters" /> </MultiBinding> </TextBlock.Text> <TextBlock>


  • Google Sheets API v4 and valueInputOption
  • Jsoup parsing an Html file with a tbody tag
  • In C,why is definition of a global variable in a separate statement raising warning,but is OK for a
  • Best style for iterating over a small number of items in Python?
  • NSDateFormatter still parsing instead having incorrect format
  • Plot a CSV file where the delimiter is '; ' (semicolon + space)
  • How to convert row to column in notepad++
  • Locating unmatched delimiters in Clojurescript
  • How to convert WPF project so it can be used as a class library by a separate exe
  • How to split row into many rows in postgresql
  • Type safe keys with Entity Framework model
  • Parenthesis() and SQL Query Performance
  • Android Lock Screen C# .NET Replica
  • jquery validation - waiting for remote check to complete
  • WP8.1 AppBarButton holding event
  • How do I display a dialog that asks the user multi-choice questıon using tkInter?
  • How can I extract results of aggregate queries in slick?
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Spring security and special characters
  • Does CUDA 5 support STL or THRUST inside the device code?
  • JSON with duplicate key names losing information when parsed
  • Trying to switch camera back to front but getting exception
  • When should I choose bucket sort over other sorting algorithms?
  • How do you troubleshoot character encoding problems?
  • AT Commands to Send SMS not working in Windows 8.1
  • Proper folder structure for lots of source files
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Free memory of cv::Mat loaded using FileStorage API
  • C# - Getting references of reference
  • Angular 2 constructor injection vs direct access
  • Understanding cpu registers
  • How do I configure my settings file to work with unit tests?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Turn off referential integrity in Derby? is it possible?
  • Add sale price programmatically to product variations
  • Is it possible to post an object from jquery to bottle.py?
  • Programmatically clearing map cache
  • Unable to use reactive element in my shiny app
  • Net Present Value in Excel for Grouped Recurring CF
  • How do I use LINQ to get all the Items that have a particular SubItem?