Make hyperlinks (and help icons) look less ass

i've been using xaml for like a year but i'm only now learning how to properly use it
This commit is contained in:
pizzaboxer 2023-10-25 13:48:45 +01:00
parent f542de5421
commit ab8b6cbe30
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
3 changed files with 39 additions and 11 deletions

View File

@ -15,6 +15,25 @@
<FontFamily x:Key="Rubik">pack://application:,,,/Resources/Fonts/#Rubik Light</FontFamily> <FontFamily x:Key="Rubik">pack://application:,,,/Resources/Fonts/#Rubik Light</FontFamily>
<Style TargetType="{x:Type Hyperlink}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorTertiary}" />
</Setter.Value>
</Setter>
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
<Setter Property="TextDecorations" Value="None" />
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorSecondary}" />
</Setter.Value>
</Setter>
</Style>
<converters:ResourceConverter x:Key="ResourceConverter" /> <converters:ResourceConverter x:Key="ResourceConverter" />
<converters:StringFormatConverter x:Key="StringFormatConverter" /> <converters:StringFormatConverter x:Key="StringFormatConverter" />
</ResourceDictionary> </ResourceDictionary>

View File

@ -50,11 +50,10 @@ namespace Bloxstrap.UI.Elements.Controls
return; return;
MarkdownDocument document = Markdown.Parse((string)dependencyPropertyChangedEventArgs.NewValue); MarkdownDocument document = Markdown.Parse((string)dependencyPropertyChangedEventArgs.NewValue);
ParagraphBlock? paragraphBlock = document.FirstOrDefault() as ParagraphBlock;
markdownTextBlock.Inlines.Clear(); markdownTextBlock.Inlines.Clear();
if (paragraphBlock == null || paragraphBlock.Inline == null) if (document.FirstOrDefault() is not ParagraphBlock paragraphBlock || paragraphBlock.Inline == null)
return; return;
foreach (var inline in paragraphBlock.Inline) foreach (var inline in paragraphBlock.Inline)
@ -71,15 +70,11 @@ namespace Bloxstrap.UI.Elements.Controls
if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(text)) if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(text))
continue; continue;
var link = new Hyperlink(new Run(text)) markdownTextBlock.Inlines.Add(new Hyperlink(new Run(text))
{ {
Command = GlobalViewModel.OpenWebpageCommand, Command = GlobalViewModel.OpenWebpageCommand,
CommandParameter = url CommandParameter = url
}; });
link.SetResourceReference(Control.ForegroundProperty, "TextFillColorPrimaryBrush");
markdownTextBlock.Inlines.Add(link);
} }
} }
} }

View File

@ -21,16 +21,30 @@
<TextBlock Grid.Column="0" FontSize="14" Text="{Binding Header, ElementName=Control}" /> <TextBlock Grid.Column="0" FontSize="14" Text="{Binding Header, ElementName=Control}" />
<TextBlock Grid.Column="1" Margin="4,0,0,0"> <TextBlock Grid.Column="1" Margin="4,0,0,0">
<TextBlock.Style> <TextBlock.Style>
<Style> <Style TargetType="TextBlock">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding HelpLink, ElementName=Control}" Value="{x:Null}"> <DataTrigger Binding="{Binding HelpLink, ElementName=Control}" Value="{x:Null}">
<Setter Property="TextBlock.Visibility" Value="Collapsed" /> <Setter Property="Visibility" Value="Collapsed" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
</TextBlock.Style> </TextBlock.Style>
<Hyperlink TextDecorations="None" ToolTip="{x:Static resources:Strings.Menu_MoreInfo}" Command="models:GlobalViewModel.OpenWebpageCommand" CommandParameter="{Binding HelpLink, ElementName=Control}"> <Hyperlink TextDecorations="None" ToolTip="{x:Static resources:Strings.Menu_MoreInfo}" Command="models:GlobalViewModel.OpenWebpageCommand" CommandParameter="{Binding HelpLink, ElementName=Control}">
<ui:SymbolIcon Symbol="QuestionCircle48" Margin="0,1,0,0" /> <ui:SymbolIcon Symbol="QuestionCircle48" Margin="0,1,0,0">
<ui:SymbolIcon.Style>
<Style TargetType="ui:SymbolIcon" BasedOn="{StaticResource {x:Type ui:SymbolIcon}}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground">
<Setter.Value>
<SolidColorBrush Color="{DynamicResource SystemAccentColorTertiary}" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ui:SymbolIcon.Style>
</ui:SymbolIcon>
</Hyperlink> </Hyperlink>
</TextBlock> </TextBlock>
</Grid> </Grid>