If a value is null I want to display the other value and display a other labeltext. How to do that in WPF/XAML without altering the underlying data-layer?
// Some pseudo-code
if a != null
my label = a
my value = a
else
my label = b
my value = b
<TextBlock Grid.Column="7" Margin="0" Grid.Row="0" Grid.RowSpan="1" TextWrapping="Wrap" Text="my label"
HorizontalAlignment="Right" FontWeight="Normal" VerticalAlignment="Center" FontSize="13.333" />
<TextBlock Grid.Column="8" Margin="5,-0.002,0,0" Grid.Row="0" Grid.RowSpan="1" TextWrapping="Wrap" Text="my value"
HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="13.333" FontWeight="Bold" />
You need to use binding converters
Binding coverter recieves the value that has to be binded before binding mechanism assigns it to a control/property. In the functions of that class you can make conversion/transformation between actual model value (for example) and the value that appears on UI. Mainly converters are used for conversion between different types: on model you have
falseon ui should haveredcolor, instead. So you should successfully acieve your goals using that.