Themes/MaterialDesignTheme.Card.xaml
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters" xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal" xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Shadows.xaml" /> </ResourceDictionary.MergedDictionaries> <Style x:Key="MaterialDesignElevatedCard" TargetType="{x:Type wpf:Card}"> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Card.Background}" /> <Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Card.Border}" /> <Setter Property="Focusable" Value="False" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type wpf:Card}"> <Grid Background="Transparent"> <AdornerDecorator CacheMode="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.CacheMode)}"> <AdornerDecorator.OpacityMask> <MultiBinding Converter="{x:Static converters:ShadowOpacityMaskConverter.Instance}"> <Binding Path="ActualWidth" RelativeSource="{RelativeSource TemplatedParent}" /> <Binding Path="ActualHeight" RelativeSource="{RelativeSource TemplatedParent}" /> <Binding Path="(wpf:ElevationAssist.Elevation)" RelativeSource="{RelativeSource TemplatedParent}" /> </MultiBinding> </AdornerDecorator.OpacityMask> <Border CornerRadius="{TemplateBinding UniformCornerRadius, Converter={x:Static convertersInternal:DoubleToCornerRadiusConverter.Instance}}" Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation), Converter={x:Static converters:ShadowConverter.Instance}}" > <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" Margin="1" CornerRadius="{TemplateBinding UniformCornerRadius, Converter={x:Static convertersInternal:DoubleToCornerRadiusConverter.Instance}}" Clip="{TemplateBinding ContentClip}"/> </Border> </AdornerDecorator> <Border CornerRadius="{TemplateBinding UniformCornerRadius, Converter={x:Static convertersInternal:DoubleToCornerRadiusConverter.Instance}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <Border x:Name="PART_ClipBorder" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" Clip="{TemplateBinding ContentClip}"> <ContentPresenter x:Name="ContentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding ContentControl.Content}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentControl.ContentTemplateSelector}" /> </Border> </Border> </Grid> <ControlTemplate.Triggers> <Trigger Property="ClipContent" Value="True"> <Setter TargetName="ContentPresenter" Property="Clip" Value="{Binding ContentClip, RelativeSource={RelativeSource TemplatedParent}}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="VerticalContentAlignment" Value="Stretch" /> <Setter Property="wpf:ElevationAssist.Elevation" Value="Dp1" /> </Style> <Style x:Key="MaterialDesignOutlinedCard" TargetType="{x:Type wpf:Card}"> <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Card.Background}" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderBrush" Value="{DynamicResource MaterialDesign.Brush.Card.Border}" /> <Setter Property="Focusable" Value="False" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type wpf:Card}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding UniformCornerRadius, Converter={x:Static convertersInternal:DoubleToCornerRadiusConverter.Instance}}"> <Border x:Name="PART_ClipBorder" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" Clip="{TemplateBinding ContentClip}"> <ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding ContentControl.Content}" ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentControl.ContentTemplateSelector}" /> </Border> </Border> <ControlTemplate.Triggers> <Trigger Property="ClipContent" Value="True"> <Setter TargetName="ContentPresenter" Property="Clip" Value="{Binding ContentClip, RelativeSource={RelativeSource TemplatedParent}}" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> <Setter Property="VerticalContentAlignment" Value="Stretch" /> </Style> </ResourceDictionary> |