Reputation: 593
I tried to set the Border on a Tile but it just doesn't want to show.
<mah:Tile Content="Tile" HorizontalAlignment="Left" Margin="692,250,0,0" VerticalAlignment="Top" BorderBrush="#FFE01C1C" BorderThickness="3"/>
No errors are thrown and i can't really see in the Source Code, https://github.com/MahApps/MahApps.Metro/blob/master/MahApps.Metro/Themes/Tile.xaml , why this wouldn't work. Any help?
Upvotes: 2
Views: 1409
Reputation: 19296
You should edit default Tile
theme.
1) Add ResourceDictionary
(TileTheme.xaml):
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro">
<Style TargetType="mah:Tile">
<Setter Property="Width"
Value="140" />
<Setter Property="Height"
Value="140" />
<Setter Property="Margin"
Value="3" />
<Setter Property="Foreground"
Value="White" />
<Setter Property="Background"
Value="{DynamicResource AccentColorBrush}" />
<Setter Property="HorizontalContentAlignment"
Value="Center" />
<Setter Property="VerticalContentAlignment"
Value="Center" />
<Setter Property="RenderTransformOrigin"
Value="0.5,0.5" />
<Setter Property="TitleFontSize"
Value="16"/>
<Setter Property="CountFontSize"
Value="28"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="mah:Tile">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid Background="{TemplateBinding Background}">
<StackPanel VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Orientation="Horizontal">
<ContentPresenter RecognizesAccessKey="True" />
<TextBlock Text="{TemplateBinding Count}"
FontSize="{Binding CountFontSize, RelativeSource={RelativeSource TemplatedParent}}"
VerticalAlignment="Center" />
</StackPanel>
<Label Grid.ColumnSpan="2"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Foreground="{TemplateBinding Foreground}">
<AccessText Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}"
Foreground="{TemplateBinding Foreground}"
TextWrapping="Wrap"
FontSize="{Binding TitleFontSize, RelativeSource={RelativeSource TemplatedParent}}"
Margin="3" />
</Label>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Button.IsPressed"
Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.98"
ScaleY="0.98"
CenterX="0.5"
CenterY="0.5" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
2) Import this resource dictionary to your app (by edit App.xaml
):
<Application ...>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="TileTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Here is example solution.
Upvotes: 1