I am using <Run Text={Binding ...}/> inside a TextBlock in order to concatenate 2 strings (one which is hard coded, the other one is a binding expression on a property). This is being done in a DataTemplate :
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="MarketOrderDataTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="70*"/>
</Grid.ColumnDefinitions>
<!-- Item icon TODO: Add Icon-->
<Image Grid.Column="0" Margin="10,0,10,0" Stretch="Fill" Source="../../Images/thumb_icon-mineral-protoss.png" />
<Separator Grid.Column="1" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<!-- Item information -->
<Grid Grid.Column="2" Margin="10,0,10,0" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="33*"/>
<RowDefinition Height="33*"/>
<RowDefinition Height="33*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0">
<Run Text="Item Name : "/>
<Run Text="{Binding Item.ItemName}"/>
</TextBlock>
<TextBlock Grid.Row="1">
<Run Text="Item ID : "/>
<Run Text="{Binding Item.ItemID}"/>
</TextBlock>
<TextBlock Grid.Row="2">
<Run Text="Item Type : "/>
<Run Text="{Binding Item.ItemType}"/>
</TextBlock>
</Grid>
<Separator Grid.Column="3" Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
<!-- Market order information -->
<Grid Grid.Column="4" Margin="10,0,10,0" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="33*"/>
<RowDefinition Height="33*"/>
<RowDefinition Height="33*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0">
<Run Text="Market Order ID : "/>
<Run Text="{Binding OrderID}"/>
</TextBlock>
<TextBlock Grid.Row="1">
<Run Text="Price : "/>
<Run Text="{Binding Price}"/>
</TextBlock>
<TextBlock Grid.Row="2">
<Run Text="Volume Remaining : "/>
<Run Text="{Binding VolumeRemaining}"/>
</TextBlock>
</Grid>
</Grid>
</DataTemplate>
</ResourceDictionary>
This works in the Item Information part of my DataTemplate (with bindings on Item.ItemName, Item.ItemID, Item.ItemType) without any problems. When I try to do the same with the Market Order Information part of my DataTemplate (with bindings on OrderID, Price, VolumeRemaining) though, it makes the application crash for some reason.
It works well if I just set the Textproperty on my TextBlock with the same binding expression, but I do not know why it makes the application crash with the <Run Text={Binding ...}/> syntax on the Market Order Info part?