【问题标题】:Mahapps Metro Controls:Tile Background ImageMahapps Metro Controls:平铺背景图像
【发布时间】:2015-08-28 18:54:33
【问题描述】:

我想用 Mahapps.Metro 创建一个酷炫的 Windows 8 外观。 我使用了<Controls:Tile/> 元素。这是我的 wpf 代码:

        <Controls:Tile Title="Artikel einstellen" TiltFactor="2" Grid.Column="0" Grid.Row="0" Width="300" Height="150">
            <Controls:Tile.Background>
                <VisualBrush Visual="{StaticResource appbar_add}" />
            </Controls:Tile.Background>
        </Controls:Tile>
        <Controls:Tile Title="Artikel verkauft" TiltFactor="2" Grid.Column="1" Grid.Row="0" Width="300" Height="150"/>
        <Controls:Tile Title="Artikel bezahlt" TiltFactor="2" Grid.Column="0" Grid.Row="1" Width="300" Height="150"/>
        <Controls:Tile Title="Artikel entfernen" TiltFactor="2" Grid.Column="1" Grid.Row="1" Width="300" Height="150"/>

现在我得到了这个结果:

但我想要这样的东西:

我下载了 MahApps.Metro 的 Icons &amp; Resource Package 并将它们包含在带有以下代码的 app.xaml 文件中:

<ResourceDictionary Source="/Resources/Icons.xaml" />

感谢您的帮助!

【问题讨论】:

    标签: c# wpf microsoft-metro


    【解决方案1】:

    MahApps.Metro.IconPacks 需要的代码更少,图标更多

    <Controls:Tile Width="300" Height="150" Grid.Column="0" Grid.Row="1" Title="Hello!">
        <Grid>
            <iconPacks:PackIconFontAwesome Kind="FlagCheckeredSolid" Foreground="#FFFFFF" Height="50" Width="50"/>
        </Grid>
    </Controls:Tile>
    

    别忘了调用命名空间

    xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
    

    【讨论】:

    • MahApps.Metro.IconPacks 占用大量空间,过多,并减慢应用程序的加载速度。如果您使用 5-10 个图标,则更容易将它们放入您自己的 xaml 字典中。
    【解决方案2】:

    我发现了问题。 我必须像这样在&lt;Tile/&gt; 内创建一个&lt;Rectangle/&gt;

    <Controls:Tile Title="Artikel einstellen" TiltFactor="2" Grid.Column="0" Grid.Row="1" Width="300" Height="150">
                <Rectangle Width="50" Height="50">
                    <Rectangle.Fill>
                        <VisualBrush Visual="{StaticResource appbar_add}" />
                    </Rectangle.Fill>
                </Rectangle>
            </Controls:Tile>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-10
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多