xaml - 图像填充按钮 UWP Xaml

标签 xaml windows-10 uwp

我在拉伸(stretch)图像以填充按钮时遇到问题,我是 UWP 的新手,这是我的代码:

 <Grid  Margin="0,0,0,54" VerticalAlignment="Bottom" Height="39" Style="{Binding HorizontalAlignment, ElementName=grid}" ScrollViewer.HorizontalScrollBarVisibility="Auto">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Button Grid.Column="0"  Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <Image Source="images/icon1.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="True" d:LayoutRounding="Auto" />

        </Button>
        <Button Grid.Column="1"  Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
            <Image Source="images/icon2.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="True" d:LayoutRounding="Auto" />
        </Button>

</Grid>

最佳答案

您可能需要更改按钮的 Padding 和 BorderThickness 属性。如下代码:

    <Button Grid.Column="0" Height="39" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0" BorderThickness="0">
        <Image Source="Assets/microsoft.png" Stretch="UniformToFill"/>
    </Button>

关于xaml - 图像填充按钮 UWP Xaml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34017031/

相关文章:

c++ - Windows 10 上的 GetTickCount 值

c++ - gmock.h 不包含在我的 Google 测试的外部依赖项中

c# - WinRT : Binding a RTF String to a RichEditBox

c# - 系统.UnauthorizedAccessException : Access to the path is denied (UWP C#)

c# - 如何尝试/捕获所有异常

c# - 来自幕后的绑定(bind)错误

WPF、Xaml 和 MS 开发的 future

c# - 如何从 XAML 内部访问嵌套命名空间?

node.js - 在 Windows 10 中浏览 docker 容器

xaml - 如何将控件高度数据绑定(bind)到另一个控件的高度?