2017-09-18 1 views
0
<Window x:Class="MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
Title="MainWindow" Height="200" Width="200"> 
<Grid> 
    <Label Content="I am very very very long sentence you have ever seen"> 
     <Label.Resources> 
      <Style TargetType="TextBlock"> 
       <Setter Property="TextWrapping" Value="Wrap" /> 
      </Style> 
     </Label.Resources> 
    </Label> 
</Grid> 
</Window> 

위의 코드는 작동하지 않습니다.Label에 TextBlock wrapping 속성을 통합하는 방법은 무엇입니까?

그래서 TextBlock 배치 속성을 Label에 통합하는 방법은 무엇입니까?

<Label> 
    <TextBlock Text="I am very very very long sentence you have ever seen" 
       TextWrapping="Wrap"/> 
</Label> 

당신이 (A 바인딩에 의해 예) 설정 가능 Content 속성을 유지하려면이 레이블의 ContentTemplate에 TextBlock에 넣어 :

답변

0

라벨의 내용에 TextBlock에 넣어

<Label Content="I am very very very long sentence you have ever seen"> 
    <Label.ContentTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding}" TextWrapping="Wrap"/> 
     </DataTemplate> 
    </Label.ContentTemplate> 
</Label> 

질문은 어떤 이유로 레이블이 있습니까?

+0

의견도 참조하십시오. https://stackoverflow.com/a/9515131/1136211 – Clemens

관련 문제