I have an itemscontrol with repeating stackpanels with child controls. Each stackpanel contains a textblock I wish to be editable. The project has a MVVM framework implemented what makes this a difficult one. I think the best way is to make a button inside each stackpanel that is connected to a BooleanToVisibilityConverter. This converter is connected to a textblock and inverted to a textbox. So it shows one of the two. The problem is I am having trouble realizing this solution.
If i bind the visibility to the back-end then this will result in showing all the textblocks or non. The solution i have now is as following:
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<CheckBox x:Name="DisplayBox" IsChecked="False"/>
<TextBlock Visibility="{Binding ElementName=DisplayBox,
Path=IsChecked,
Converter={StaticResource BoolToVis}}">
<Run Text="{Binding Title}"/>
</TextBlock>
</StackPanel>
So my question is: Is there a simple way to implement an editable textblock with only XAML binded to each control? Or do I need to implement a way that connects it to the back-end.
CheckBox
? – dkozlTextBox
? – dkozl