Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, after some more digging, I've figured this out to my satisfaction. I'm binding to RelativeSource Self and then parsing the binding expression on the Text property (since this is a TextFieldMaxLength converter, I am presuming I'm working against a TextBox.</p> <p>The styling up in the resource dictionary:</p> <pre><code>&lt;Style TargetType="TextBox"&gt; &lt;Setter Property="MaxLength"&gt; &lt;Setter.Value&gt; &lt;Binding Converter="{StaticResource textFieldMaxLengthConverter}" RelativeSource="{RelativeSource Self}" /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>The usage (basically showing nothing special needs to be done since it's all in the style):</p> <pre><code>&lt;TextBox Text="{Binding MyPropertyName.TheirPropertyName}" /&gt; </code></pre> <p>The Convert Method for the textFieldMaxLengthConverter:</p> <pre><code>public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { Control control = value as Control; BindingExpression be = control.GetBindingExpression(TextBox.TextProperty); if (be != null) { string boundPropertyName = be.ParentBinding.Path.Path; // .. boundPropertyName here is MyPropertyName.TheirPropertyname, do some parsing and return a value based on that } } </code></pre> <p>(Obviously my actual implementation is a bit more complex/handles unexpected input/uses reflection as per my original question's statement).</p> <p>Anyway, thought I would post this solution in case anyone else tries to do something similar, or if there might be a better way to do this than I am using.</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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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