I'm working on a WPF application and I need to italicize some text in front of a string variable that is displayed on the same line. I want to use:
<TextBlock Foreground="LightGray" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18" Margin="20,0,0,0" TextWrapping="Wrap">
<Run Text="Conflicts: " FontStyle="Italic"/>
<Run Text="{Binding ElementName=DropDown, Path=SelectedItem.Conflicts}" />
</TextBlock>
But when I do this the app freezes. No error, and it isn't just taking a long time, unless for some reason it's taking 5+ minutes to load like 1 line of code, which I do not suspect.
However I know it can load the string variable because it works perfectly fine when I use:
<TextBlock Foreground="LightGray" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18" Text="{Binding ElementName=DropDown, Path=SelectedItem.Conflicts}" Margin="20,0,0,0" TextWrapping="Wrap"/>
I am fairly new to XAML, so it's possible I'm missing something obvious but I have no idea why one works and the other does not. Using Run Text never seems to work for me if bound to a string variable, but I can have it work with explicit text like:
<TextBlock Foreground="LightGray" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="18" Margin="20,0,0,0" TextWrapping="Wrap">
<Run Text="Conflicts: " FontStyle="Italic"/>
</TextBlock>
I need to have them appear on the same line, so if anyone knows how to get Text Run to work with a string variable or to somehow ignore the newline created from using two textblocks that would be a big help.
I have also tried using a converter with Run Text but anything that uses a string variable with Run Text seems to freeze the application.
<Run Text="{Binding ElementName=DropDown, Path=SelectedItem.Conflicts, Mode=OneTime}" />work better? What does theConflictsproperty return?