2011-12-09 22 views
1

我有以下XAML:XAML標籤:使用文本樣式時,結合課文內容

<Label> 
    <Underline Foreground="Blue">Foo</Underline> 
</Label> 

現在我想更換使用綁定在運行時的文本「富」,但顯然我不能到位這裏有一個代替Foo的{..}綁定。什麼是正確的方法來做到這一點?

+0

CONTENT =「{結合文字}?(只是猜測) –

+0

它通常是「CONTENT =」 {結合文本}',這是一個很好的猜測,但是這個控制是不同的。非常意外。 – peter

回答

4

我碰到這個來了,

<Label> 
    <Underline Foreground="Blue"> 
     <Underline.Inlines> 
      <TextBlock Text="{Binding Text}"></TextBlock> 
     </Underline.Inlines> 
    </Underline> 
</Label> 

而事實上,你可以減少到這一點,

<Label> 
    <Underline Foreground="Blue"> 
     <TextBlock Text="{Binding Text}"></TextBlock> 
    </Underline> 
</Label> 

或者你也可以像這樣做,

<Label Name="label"> 
    <TextBlock Name="textBlock" TextDecorations="Underline" Text="Test"/> 
</Label> 

所以回給你的文字'Foo'強調你正在定義一個內聯。

http://msdn.microsoft.com/en-us/library/system.windows.documents.underline.aspx

它說這個,

導致內容有下劃線的文字裝飾渲染內聯級流內容元素。

所以這是一組內聯的,並採取這種格式,

<Underline> 
    Inlines 
</Underline> 
相關問題