2012-05-12 125 views
0

我是windows phone 7中的新手。 我正在做一個樣本,用於製作windows phone 7中silverlight的圓角按鈕。 我實現了圓角。但它沒有顯示按鈕的內容。 我的代碼有什麼問題? 請幫幫我。silverlight windows phone 7中的按鈕問題

現在我的按鈕看起來像這樣。沒有文字。 enter image description here

我在下面發佈了我的代碼。

謝謝。

MainPage.xaml中

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <StackPanel VerticalAlignment="Center"> 
      <Button Width="200" Height="80" Content="Click Me" Style="{StaticResource myCustomButtonStyle}" > 
       </Button> 
     </StackPanel> 
    </Grid> 

ButtonResourceDictionary.xaml

<LinearGradientBrush x:Key="myCustomButtonColor" EndPoint="0.5,1" StartPoint="0.5,0"> 
    <GradientStop Color="#FF296180" Offset="0.589"/> 
    <GradientStop Color="#FF5BC0F3"/> 
</LinearGradientBrush> 

<Style x:Name="myCustomButtonStyle" TargetType="Button"> 
    <Setter Property="BorderThickness" Value="0"></Setter> 
    <Setter Property="Template"> 
     <Setter.Value> 
      <ControlTemplate TargetType="Button"> 
       <Border x:Name="buttonBorder" Background="{StaticResource myCustomButtonColor}" CornerRadius="12"></Border> 

      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 

回答

1

你需要一個 'ContentPresenter' 元素添加到您的模板來顯示內容

+0

Thankx。它解決了我的問題。 – Arun