1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 22:45:44 +00:00

Style variable en fonction du header

This commit is contained in:
Yan Maniez 2018-08-05 22:10:56 +02:00
parent 955ec2eaba
commit 55f522cb55
2 changed files with 21 additions and 1 deletions

View file

@ -33,4 +33,23 @@ namespace AideDeJeu.Tools
return null;
}
}
public class HeaderLevelToStyleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var level = value as int?;
if(level.HasValue)
{
return Application.Current.Resources[$"heading{level.Value+1}"];
}
return Application.Current.Resources["paragraph"];
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View file

@ -12,6 +12,7 @@
<ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
<tools:HeaderLevelToStyleConverter x:Key="HeaderLevelToStyleConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
@ -29,7 +30,7 @@
<DataTemplate>
<ViewCell AutomationProperties.IsInAccessibleTree="True" AutomationId="machin" AutomationProperties.Name="hop">
<StackLayout Padding="10" Orientation="Vertical">
<Label Text="{Binding DisplayName}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="16" />
<Label Text="{Binding DisplayName}" LineBreakMode="NoWrap" Style="{Binding NameLevel,Converter={StaticResource HeaderLevelToStyleConverter}}" />
<Label Text="{Binding AltNameText}" LineBreakMode="NoWrap" Style="{DynamicResource subsubsection}" FontSize="12" />
</StackLayout>
</ViewCell>