放大按钮的DataTemplate图像

时间:2015-02-04 14:55:18

标签: wpf

我正在尝试将按钮内的图标图像设为更大。我想知道我是怎么做的。

    <Button ContentTemplate="{StaticResource Icons.Home}"  Width="60" Height="40">
    </Button>

http://snag.gy/ARTls.jpg

我已经更改了资源字典中的Icons.Home的宽度和高度,但似乎没有驱动因素。

图标代码,如果它起作用因子

<Viewbox>
    <Grid>
    <Grid Name="backgroundGrid" Width="256" Height="256" Visibility="Collapsed" />
    <Path Data="M10.867,0L15.175004,3.5474122 15.175004,0.66600073 17.616003,0.66600073 17.616003,5.5574448 22.066,9.2217805 18.980004,9.2217805 18.980004,16.776999 12.422999,16.776999 12.422999,11.443829 9.3120081,11.443829 9.3120081,16.776999 2.7570027,16.776999 2.7570027,9.2217805 0,9.2217805z" Stretch="Uniform" Fill="#FF243670" Width="256" Height="256" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
      <Path.RenderTransform>
        <TransformGroup>
          <TransformGroup.Children>
            <RotateTransform Angle="0" />
            <ScaleTransform ScaleX="1" ScaleY="1" />
          </TransformGroup.Children>
        </TransformGroup>
      </Path.RenderTransform>
    </Path>
  </Grid>
</Viewbox>

2 个答案:

答案 0 :(得分:0)

刚刚找到答案,

如果我改变了ScaleTransform,它会增加Icon Image。 改变X = 2和Y = 2,它完美地运作

答案 1 :(得分:0)

请使用内容属性来覆盖按钮模板,如下所示

 <Button Style="{StaticResource CommonMainButtonStyle}"
                        Command="{Binding HadaProblemCommand}">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="75"/>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Style="{StaticResource CommonSubHeaderTextBlockStyle}" Text="Report Problem"/>
                        <Image Grid.Row="1" Height="150" Margin="25" Width="150" Stretch="Uniform" Source="WorksImages/13-002.png"></Image>
                    </Grid>
                </Button>