找回密码
 立即注册

QQ登录

只需一步,快速开始

bj_zm

中级会员

48

主题

169

帖子

713

积分

中级会员

积分
713

活字格认证微信认证勋章

bj_zm
中级会员   /  发表于:2014-4-8 03:35  /   查看:5627  /  回复:3
如题?
    <Style x:Key="stC1MessageBox" TargetType="c1:C1MessageBoxContent">
        <Setter Property="FontSize" Value="14"/>
        <Setter Property="FontFamily" Value="{StaticResource StandardFontFamily}" />
    </Style>
这只换了内容字体。背景色和图标怎么更换?


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

3 个回复

倒序浏览
roger.wang
社区贡献组   /  发表于:2014-4-8 14:49:00
沙发
回复 1楼bj_zm的帖子

请参考完整的自定义模板代码:

  1.             <Style x:Name="C1MessageBoxContentStyle1" TargetType="c1:C1MessageBoxContent">
  2.                 <Setter Property="OKText" Value="OK"/>
  3.                 <Setter Property="CancelText" Value="Cancel"/>
  4.                 <Setter Property="YesText" Value="Yes"/>
  5.                 <Setter Property="NoText" Value="No"/>
  6.                 <Setter Property="ButtonStyle">
  7.                     <Setter.Value>
  8.                         <Style TargetType="Button">
  9.                             <Setter Property="Margin" Value="5,0,5,0"/>
  10.                             <Setter Property="VerticalAlignment" Value="Center"/>
  11.                             <Setter Property="MinWidth" Value="75"/>
  12.                             <Setter Property="Background" Value="Green"></Setter>
  13.                         </Style>
  14.                     </Setter.Value>
  15.                 </Setter>
  16.                 <Setter Property="Template">
  17.                     <Setter.Value>
  18.                         <ControlTemplate TargetType="c1:C1MessageBoxContent">
  19.                             <Grid Width="350" Background="#FFF29191">  <!--背景色-->
  20.                                 <Grid.RowDefinitions>
  21.                                     <RowDefinition/>
  22.                                     <RowDefinition Height="50"/>
  23.                                 </Grid.RowDefinitions>
  24.                                 <Grid Margin="10">
  25.                                     <Grid.ColumnDefinitions>
  26.                                         <ColumnDefinition Width="Auto"/>
  27.                                         <ColumnDefinition/>
  28.                                     </Grid.ColumnDefinitions>
  29.                                     <Image Height="48" Margin="0,0,20,0" x:Name="Icon" Width="48" Stretch="None" />
  30.                                     <TextBlock VerticalAlignment="Center" Grid.Column="1" Text="{TemplateBinding Message}" TextWrapping="Wrap" FontWeight="Bold" FontStyle="Italic"/>
  31.                                 </Grid>
  32.                                 <Grid Grid.Row="1" Background="#FFF0F0F0">
  33.                                     <Grid.RowDefinitions>
  34.                                         <RowDefinition Height="*"/>
  35.                                         <RowDefinition Height="Auto"/>
  36.                                         <RowDefinition Height="*"/>
  37.                                     </Grid.RowDefinitions>
  38.                                     <StackPanel HorizontalAlignment="Right" Margin="0,0,5,0" x:Name="Buttons" VerticalAlignment="Center" Grid.Row="1" Orientation="Horizontal"/>
  39.                                 </Grid>
  40.                             </Grid>
  41.                         </ControlTemplate>
  42.                     </Setter.Value>
  43.                 </Setter>
  44.             </Style>
复制代码
回复 使用道具 举报
bj_zm
中级会员   /  发表于:2014-4-8 17:19:00
板凳
回复 2楼roger.wang的帖子

好用,非常感谢。
回复 使用道具 举报
roger.wang
社区贡献组   /  发表于:2014-4-8 17:25:00
地板
回复 3楼bj_zm的帖子

nice
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部