Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/AvaloniaInside.Shell/NavigationBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml.Templates;

namespace AvaloniaInside.Shell;

Expand Down Expand Up @@ -327,6 +328,33 @@ public static void SetHeaderIcon(AvaloniaObject element, object parameter) =>

#endregion


#region HeaderTemplate

public static readonly AttachedProperty<DataTemplate> HeaderTemplateProperty =
AvaloniaProperty.RegisterAttached<NavigationBar, AvaloniaObject, DataTemplate>("HeaderTemplate");

public static DataTemplate GetHeaderTemplate(AvaloniaObject element) =>
element.GetValue(HeaderTemplateProperty);

public static void SetHeaderTemplate(AvaloniaObject element, DataTemplate parameter) =>
element.SetValue(HeaderTemplateProperty, parameter);

#endregion

#region HeaderIconTemplate

public static readonly AttachedProperty<DataTemplate> HeaderIconTemplateProperty =
AvaloniaProperty.RegisterAttached<NavigationBar, AvaloniaObject, DataTemplate>("HeaderIconTemplate");

public static DataTemplate GetHeaderIconTemplate(AvaloniaObject element) =>
element.GetValue(HeaderIconTemplateProperty);

public static void SetHeaderIconTemplate(AvaloniaObject element, DataTemplate parameter) =>
element.SetValue(HeaderIconTemplateProperty, parameter);

#endregion

#region Visible

public static readonly AttachedProperty<bool> VisibleProperty =
Expand Down Expand Up @@ -507,6 +535,7 @@ protected virtual void UpdateHeader(object? view, ContentControl itemPresenter)
{
itemPresenter.DataContext = element.DataContext ?? element;
itemPresenter[!ContentControl.ContentProperty] = element[!HeaderProperty];
itemPresenter[!ContentControl.ContentTemplateProperty] = element[!HeaderTemplateProperty];
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HeaderIconTemplate property is not being bound in the UpdateHeader method, creating inconsistency with the HeaderTemplate implementation. Consider adding a similar binding for HeaderIconTemplate if this method handles icon updates.

Copilot uses AI. Check for mistakes.
return;
}

Expand Down
12 changes: 7 additions & 5 deletions src/AvaloniaInside.Shell/Theme/Default/TabPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@
<Setter Property="ItemTemplate">
<DataTemplate DataType="{x:Type NavigationChain}">
<Grid RowDefinitions="*,*" Width="70">
<ContentPresenter Grid.Row="0"
<ContentControl Grid.Row="0"
DataContext="{Binding Instance}"
Content="{Binding Path=(NavigationBar.HeaderIcon)}"></ContentPresenter>
<TextBlock Grid.Row="1"
Content="{Binding Path=(NavigationBar.HeaderIcon)}"
ContentTemplate="{Binding Path=(NavigationBar.HeaderIconTemplate)}"/>
<ContentControl Grid.Row="1"
DataContext="{Binding Instance}"
Text="{Binding Path=(NavigationBar.Header)}"
Content="{Binding Path=(NavigationBar.Header)}"
ContentTemplate="{Binding Path=(NavigationBar.HeaderTemplate)}"
FontSize="14"
HorizontalAlignment="Center"></TextBlock>
HorizontalAlignment="Center"></ContentControl>
Comment on lines 55 to +56
Copy link

Copilot AI Jul 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FontSize property is applied to a ContentControl but may not be effective since ContentControl doesn't directly render text. Consider moving this property to the ContentTemplate or removing it if the template should handle text styling.

Copilot uses AI. Check for mistakes.
</Grid>
</DataTemplate>
</Setter>
Expand Down
Loading