microsoft / XamlBehaviorsWpf

Home for WPF XAML Behaviors on GitHub.
MIT License
854 stars 140 forks source link

Question: Workaround like Interaction.Behaviors for custom attached properties #100

Closed HavenDV closed 2 years ago

HavenDV commented 2 years ago

I'm trying to work around a problem like this: The object 'Label' already has a child and cannot add ''. 'Label' can only accept one child.

<Label Grid.Column="1"
       Grid.Row="1">
    <ui:Helper.Text>
        <PriorityBinding>
            <Binding Path="Worker.Employer.Name" StringFormat="Employer: {0}" />
            <Binding Source="Unemployed" />
        </PriorityBinding>
    </ui:Helper.Text>
    <Binding RelativeSource="{RelativeSource Self}" Path="(ui:Helper.Text)" />
</Label>

SO: https://stackoverflow.com/questions/17179746/the-object-label-already-has-a-child-and-cannot-add-label-can-accept-onl

I see that Interaction.Behaviors gets around this limitation but couldn't replicate this using the approach from https://github.com/microsoft/XamlBehaviorsWpf/blob/master/src/Microsoft.Xaml.Behaviors/Interaction.cs What else is required besides this approach for this to work?

brianlagunas commented 2 years ago

I'm sorry, but this is not the place to ask questions regarding your custom behaviors or attached properties. Please ask these types of question in other forums like SO.