2011-01-19 4 views
0

こんにちは私は、ラベルとエキスパンダーコントロールのための丸い角でスタイルを作ってみてください。ラウンドコーナーのラベルとエキスパンダーコントロール

ラベルのスタイル:私はビューでこのスタイルに多使用

 <Style x:Key="InfoLabelStyle" TargetType="{x:Type Label}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type Label}"> 
         <Border Name="Border" Background="#BFE3FE" BorderBrush="#BFE3FE" BorderThickness="1" CornerRadius="7" Padding="3"> 
         </Border> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
      <Setter Property="FontSize" Value="12"/> 
      <Setter Property="FontWeight" Value="Normal"/> 
      <Setter Property="Height" Value="25"/> 
      <Setter Property="VerticalAlignment" Value="Center"/> 
      <Setter Property="BorderThickness" Value="1"/> 
      <Setter Property="BorderBrush" Value="#BFE3FE"/> 
      <Setter Property="Background" Value="#BFE3FE"/> 
      <Setter Property="Margin" Value="2,4,0,1" /> 
      <Setter Property="Padding" Value="4,0,0,0" /> 
     </Style> 

    <Label Style="{StaticResource InfoLabelStyle}"> 
         <Label.Content> 
          <MultiBinding StringFormat="{}{0}, {1} rokov"> 
           <Binding Path="Oponent.Info.Sex" Converter="{StaticResource sexConverter}"/> 
           <Binding Path= "Oponent.Info.Age"/> 
          </MultiBinding> 
         </Label.Content> 
         </Label> 

をしかし、私はアプリを実行した場合、このラベルの内容が空で、結合は良いですが、私はそれを試してみてくださいテキストボックスのコントロールと作業。

第2の問題は、エキスパンダーコントロールで角を丸くしたいということです。

私はラベルスタイルと同様にしてみてください:パンダコントロール上

 <Style x:Key="InfoExpanderStyle" TargetType="{x:Type Expander}"> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="{x:Type Expander}"> 
         <Border Name="Border" Background="#BFE3FE" BorderBrush="#BFE3FE" BorderThickness="1" CornerRadius="7" Padding="3"> 
         </Border> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 

Appluスタイル:

 <Expander Name="InfoExapnder" 
         Header="{Binding Path=Oponent.Info.Nick, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" 
         Style="{StaticResource InfoExpanderStyle}" 
         IsExpanded="True" 
         FontSize="18" 
         FontWeight="Normal" 
         Background="#ECEBEB" 
         Margin="3,0,3,0" 
         Grid.Row="0"> 
       <Grid> 
</Grid> 

をしかし、結果は同じ制御、空の内容です。

私は何が悪いですか?

答えて

1

ラベルは再テンプレートされていますが、コンテンツを配置する場所を指定していないため、空です。あなたは次のようなものを望みます:

   <ControlTemplate TargetType="{x:Type Label}"> 
        <Border Name="Border" Background="#BFE3FE" BorderBrush="#BFE3FE" BorderThickness="1" CornerRadius="7" Padding="3"> 
         <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/> 
        </Border> 
       </ControlTemplate> 
関連する問題