如何更改"详细信息标题"部分



我有一个Xamarin Forms应用程序,它唯一支持的平台是UWP。我使用Master Detail架构。我知道如何更改详细信息页面的标题文本,但我需要更改例如标题窗格的高度及其背景色。我想这应该在MySolution.UWP项目上完成,但不知道如何处理。我甚至不知道我应该改变什么,TopCommandBarArea,或CommandBar,或LayoutRoot等

以下是我在共享项目中的一些代码:

private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as MainMDPageMenuItem;
if (item == null)
return;
item.ItemBackgroundColor = Color.FromHex("#006c89");
if (PreviouslySelectedItem != null)
{
PreviouslySelectedItem.ItemBackgroundColor = Color.FromHex("#00a8d5");
}
var page = (Page)Activator.CreateInstance(item.TargetType);
page.Title = item.Title;
Detail = new NavigationPage(page);
IsPresented = false;
MasterPage.ListView.SelectedItem = null;
PreviouslySelectedItem = item;
}

要更改标题栏背景颜色,请在Xamarin Forms Project中的App.Xaml中添加以下代码段:

<Application.Resources>
<ResourceDictionary>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor"
Value="Maroon"></Setter>
<Setter Property="BarTextColor"
Value="Violet"></Setter>
</Style>
</ResourceDictionary>
</Application.Resources>

要更改字体属性,请在UWP项目App.Xaml中添加以下代码片段

<Application.Resources>
<ResourceDictionary>
<Style x:Key="TitleTextBlockStyle"
BasedOn="{StaticResource BaseTextBlockStyle}"
TargetType="TextBlock">
<Setter Property="FontWeight"
Value="SemiLight" />
<Setter Property="FontSize"
Value="36" />
<Setter Property="OpticalMarginAlignment"
Value="TrimSideBearings" />
</Style>
</ResourceDictionary>
</Application.Resources>

最新更新