I have a series of TextBlock
and TextBox
controls. Is there a way to apply a Style
to the TextBlock
s such that they can databind to the control immediately after them?
I'd like to be able to do something like this:
<Resources..>
<Style x:Key="BindToFollowingTextBoxSibling">
<Setter Property="TextBlock.Text" Value="{Binding RelativeSource={RelativeSource FollowingSibling}, Path=Text, Converter={StaticResource MyConverter}}" />
<Setter Property="TextBlock.Background" Value="{Binding RelativeSource={RelativeSource FollowingSibling}, Path=Text, Converter={StaticResource TextToBrushConverter}}" />
... More properties and converters.
</Style>
</Resources>
...
<TextBlock Style="{StaticResource BindToFollowingTextBoxSibling}"/>
<TextBox/>
<TextBlock Style="{StaticResource BindToFollowingTextBoxSibling}"/>
<TextBox/>
<TextBlock Style="{StaticResource BindToPreviousTextBoxSibling}"/>
Is something like this even possible?