2014-11-04 124 views
0

我的Windows Phone應用程序具有帶有一些綁定值的ListBox。XAML對象覆蓋另一個

TextBlock Binding unidade覆蓋TextBlock Binding quantidade當有更多的3個字符時。

如何做到這一點(邊際),數量增加時改變。

enter image description here

<controls:PivotItem Header="Consulta" Name="consultaCartao"> 
      <Grid> 
       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="Auto" /> 
        <ColumnDefinition Width="Auto" /> 
        <ColumnDefinition Width="Auto" /> 
       </Grid.ColumnDefinitions> 
       <ListBox Name="List2" ItemsSource="{Binding produtosCartao}" HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3" Margin="0,182,-66,0" Visibility="Collapsed"> 
        <ListBox.ItemTemplate> 
         <DataTemplate> 
          <StackPanel Margin="0,0,0,17" Width="432" Height="Auto"> 
           <StackPanel.Background> 
            <SolidColorBrush Color="#FFE8FF00" Opacity="0.2"/> 
           </StackPanel.Background> 
           <TextBlock Grid.Column="0" Text="{Binding descricao}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/> 
           <TextBlock Grid.Column="3" Text="{Binding quantidade}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" Margin="20,5,12,0"/> 
           <TextBlock Grid.Column="3" Text="{Binding valor_preco_a, ConverterCulture=pt-BR, StringFormat=C2}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="300,-30,12,0"/> 
           <TextBlock Grid.Column="3" Text="{Binding unidade}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="43,-27,12,0"/> 
          </StackPanel> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 
       </ListBox> 

回答

2

我會用內聯元素Run

<TextBlock Grid.Column="3" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="43,-27,12,0"> 
    <Run Text="{Binding unidade}" /> 
    <Run Text="{Binding quantidade}" /> 
</TextBlock> 

這樣的 「KG」 將始終從數遵循。