2013-06-10 3 views
5

일부 바운드 데이터를 표시하기 위해 StringFormat을 사용하고 있으며 정상적으로 작동합니다. 글꼴 체중을 사용하는 StringFormat

<TextBlock> 
    <TextBlock.Text> 
     <MultiBinding StringFormat="Name {0} | Id ({1})"> 
      <Binding Path="Name" /> 
      <Binding Path="Id"/> 
     </MultiBinding> 
    </TextBlock.Text> 
</TextBlock> 

은 내가 Id 값 (XAML 참조) 대담하고 싶습니다. 이 작업을 수행하는 방법?

답변

9

사용 Run (및/또는 Bold) 요소 inside the TextBlockText 재산의 대신에, 당신은 바인딩하고 개별적으로 스타일을 지정할 수 있습니다.

예컨대 <Run Text="{Binding Id}" FontWeight="Bold"/>에 선택적으로

<TextBlock> 
    <Run Text="Name "/><Run Text="{Binding Name}"/> 
    <Run Text=" | "/> 
    <Run Text="Id ("/><Run Text="{Binding Id}" FontWeight="Bold"/><Run Text=")"/> 
</TextBlock> 

: 하나 아래

<Bold><Run Text="{Binding Id}"/></Bold> 
+0

하지 :(어떻게 내 게시 XAML에서 저를 보여 주실 래요? – Stacked

+0

을 당신도 내가 링크 된 문서를 읽어 적이 있습니까? –

2

시도. 나를 위해 충분히 명확

<TextBlock Margin="12,0,355,13" Grid.Row="2" TextAlignment="Left">    
      <Run Text="Name " /> 
      <Run Text="{Binding EmpName}" TextDecorations="Underline"/> 
      <Run Text=" | " /> 
      <Run Text="Id "/> 
      <Run Text="{Binding Id}" FontWeight="Bold"/> 
     </TextBlock> 
관련 문제