2014-03-26 5 views
1

텍스트를 타원형으로 표시하려고합니다. 내가 현재 가지고있는 코드입니다 : 내가 요청한대로실버 라이트의 타원 위의 텍스트

<Button Grid.Column="2" Template="{StaticResource ThresholdBtnTemp}" Background="Green"> 
    <TextBlock Text="0" Foreground="Black" VerticalAlignment="Center" HorizontalAlignment="Center"/> 
</Button> 
<Button Grid.Column="3" Template="{StaticResource ThresholdBtnTemp}" Background="Yellow" /> 
<Button Grid.Column="4" Template="{StaticResource ThresholdBtnTemp}" Background="Red" Content="2" /> 

<ControlTemplate x:Key="ThresholdBtnTemp" TargetType="Button" > 
    <Ellipse Fill="{TemplateBinding Background}" Stroke="Black" Margin="2" /> 
</ControlTemplate> 

레드 나 그린 어느 쪽이 값을 표시합니다. 어떤 제안?

답변

0

콘텐츠를 "표시"하려면 컨트롤 템플릿을 변경해야합니다. ControlTemplate을 다음으로 변경하십시오.

<ControlTemplate x:Key="ThresholdBtnTemp" TargetType="Button" > 
    <Grid> 
     <Ellipse Fill="{TemplateBinding Background}" Stroke="Black" Margin="2" /> 
     <ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" /> 
    </Grid> 
</ControlTemplate> 
+0

감사합니다. – VanCowboy