Windows Phone 8 xaml文本块绑定格式

Boh*_*end 1 xaml datatemplate windows-phone-8

我想格式化一个绑定到值的文本块,在实际值之前显示"R",这是可能的,因为我不能直接更改值?

谢谢

<ListBox x:Name="lstbundleListbox"
         Foreground="White"
         Height="320"
         HorizontalAlignment="Center">
  <ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
      <Setter Property="HorizontalContentAlignment"
              Value="Center" />
    </Style>
  </ListBox.ItemContainerStyle>
  <ListBox.ItemTemplate>
    <DataTemplate>
      <StackPanel>
        <TextBlock Text="{Binding name}"
                   TextWrapping="Wrap"
                   HorizontalAlignment="Center" />

        <TextBlock Text="{Binding cost}"
                   TextWrapping="Wrap"
                   HorizontalAlignment="Center" />
      </StackPanel>
    </DataTemplate>
  </ListBox.ItemTemplate>
  <ItemsControl.ItemsPanel>
    <ItemsPanelTemplate>
      <StackPanel Orientation="Vertical" />
    </ItemsPanelTemplate>
  </ItemsControl.ItemsPanel>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

所以我基本上希望文本块显示R(成本)

Ash*_*ani 8

使用 Run

<TextBlock>
    <Run Text="R" />
    <Run Text="{Binding cost}" />
</TextBlock>
Run Code Online (Sandbox Code Playgroud)

或使用 StringFormat

<TextBlock Text="{Binding cost, StringFormat=R{0}}" />
Run Code Online (Sandbox Code Playgroud)