Note that there are some explanatory texts on larger screens.

plurals
  1. POPass value of a field to Silverlight ConverterParameter
    primarykey
    data
    text
    <p>I'm writing my very first Silverlight app. I have a datagrid with a column that has two labels, for the labels, i am using an IValueConverter to conditionally format the data. </p> <p>The label's "Content" is set as such: </p> <pre><code>Content="{Binding HomeScore, Converter={StaticResource fmtshs}}" </code></pre> <p>and </p> <pre><code>Content="{Binding AwayScore, Converter={StaticResource fmtshs}}" </code></pre> <p>The <strong>Convert</strong> method of my IValueConverter is such: </p> <pre><code>Public Function Convert( ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert Dim score As Long = value, other As Long = parameter Return If(score &lt; 0, "", If(score - other &gt; 5, (other + 5).ToString, score.ToString) ) End Function </code></pre> <p>So what i want to do is in the converter for HomeScore, i want to pass AwayScore to the ConverterParameter, and for AwayScore i want to pass the HomeScore to the converter. In the converter for either score i need to be able to know the value of the other score for formatting purposes. </p> <p>But i cannot figure out the syntax for binding the ConverterParameter to another field.<br> I've tried the following: </p> <pre><code>Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter=AwayScore}" Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter={AwayScore}}" Content="{Binding HomeScore, Converter={StaticResource fmtshs}, ConverterParameter={Binding AwayScore}}" </code></pre> <p>But none of those seem to work. How do i pass a field value to the ConverterParameter?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload