I have a custom UserControl with 2 templates. I have to bind from a control in the first template to a control in the second template.
When I try to give the target control a name, then I get:
Cannot set Name attribute value 'TheRichTextBox' on element 'RichTextBox'. 'RichTextBox' is under the scope of element 'CustomElement', which already had a name registered when it was defined in another scope.
So I have to work with relative binding, but my only options are to look up or down the visual tree.
Is there a good solution for this scenario?
<local:CustomElement Title="CustomElementInstance" >
<local:CustomElement.SubHeaderContainer>
<StackPanel Orientation="Horizontal">
<ToggleButton
IsChecked="{Binding Path=KladblokEditingState}"
Command="{Binding Path=UpdateKladblokCommand}" CommandParameter="{Binding TheRichTextBox????, Path=Document}"/>
</StackPanel>
</local:CustomElement.SubHeaderContainer >
<RichTextBox IsReadOnly="{Binding Path=KladblokEditingNotState}"
local:RichTextBoxHelper.DocumentXaml="{Binding Path=Kladblok.KladblokDocument}" />
</local:CustomElement>