1
好的,我已經定義了導航窗口的樣式。我已成功設置了導航按鈕樣式,甚至將頁面麪包屑添加到導航菜單。我想要的是添加旁邊的麪包屑頁面標題:將頁面標題綁定到樣式中的文本塊
Style x:Key="{x:Type NavigationWindow}" TargetType="NavigationWindow">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="NavigationWindow">
<DockPanel Background="{StaticResource WindowBackgroundBrush}">
...
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="16"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
....
<StackPanel Grid.Column="4" Orientation="Horizontal">
<TextBlock Foreground="Gray"
VerticalAlignment="Center"
Text="{Binding Path=Title,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type Page}}}" />
</StackPanel>
</Grid>
</DockPanel>
...
</ControlTemplate>
</Setter.Value>
</Setter>
綁定不過去TextBlock的工作。 (然而,如果不在樣式中使用,但在常規的XAML頁面代碼隱藏中,它工作得很好),我不知道爲什麼。幫幫我?如何讓它顯示當前頁面標題?謝謝。
讓我更具體: 我已經設置了二傳手 這暴露了導航窗口的標題,與Page.WindowTitle相同。但是,我需要的是Page.Title屬性。你能幫忙嗎? –
Boris
2009-08-25 17:18:48