Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF binding to another property's binding in a style
    primarykey
    data
    text
    <p>I'm not sure the best way to ask this question (sorry for the ambiguous question title), but essentially I'd like to set the MaxLength property on a TextBox using a value converter that is passed in a property from the data context, and the property on the passed-in property as the converter parameter. I'd like to do all this in a style, as opposed to on a control-by-control basis. Here's an example of doing this in a non-styled manner:</p> <pre><code>&lt;TextBox Text="{Binding MyPropertyName.TheirPropertyName}" MaxLength="{Binding MyPropertyName, Converter={StatocRespirceMyCoolConverter}, ConverterParameter=TheirPropertyName}" /&gt; </code></pre> <p>(In case you're wondering, TheirPropertyName represents a property on the type of MyPropertyName that has an attribute like [StringMaxLength(15)], which I'd be able to get to and return inside the value converter.) Additionally, is there any way to pass in the type of MyPropertyName as opposed to the instance? I only need the type to do the StringMaxLength attribute lookup.</p> <p>Anyway, how could I go about doing something like this in a style? I've gotten as far as:</p> <pre><code>&lt;Setter Property="MaxLength"&gt; &lt;Setter.Value&gt; &lt;Binding Converter="{StaticResource textFieldMaxLengthConverter}" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; </code></pre> <p>But that passes the overall datacontext in to the value converter, as opposed to the MyPropertyName object, and I really have no clue if I can have it parse the MyPropertyName.TheirPropertyName part of the binding to pass TheirPropertyName in on the ConverterParameter attribute of the binding.</p> <p>Any guidance would be really appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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