2013-10-27 2 views
3

WPF 텍스트 블록에서 다른 색상의 텍스트 안에 내용을 어떻게 작성합니까?WPF 텍스트 블록, 전경색 혼합

<Label FontSize="32" Foreground="White"> 
     <TextBlock TextWrapping="Wrap" Text="Player 1 just win XXX Game from CK." /> 
</Label> 

예를 들어, 전체 문장은 화이트 색상에 있지만 WPF는 그렇게 할 수 내가 다른 색으로 "플레이어 1"과 "CK"를해야합니까?

답변

4

당신은 할 수 Inlines

<TextBlock TextWrapping="Wrap"> 
    <TextBlock.Inlines> 
     <Run Foreground="Red" Text="Player 1"/> 
     <Run Foreground="White" Text=" just win XXX Game from"/> 
     <Run Foreground="Green" Text=" CK" /> 
    </TextBlock.Inlines> 
</TextBlock> 
를 사용하여
관련 문제