[英]How to set title of a page that hosted by a frame window?
我有一個用於托管頁面的框架窗口。
//inside frame window
public partial class FrameWindow : Window
{
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Main.Content = new Example_Page();
}
}
我看到了此解決方案,但由於該頁面由窗口框架托管,因此無法使用。 那么,如何設置頁面標題並顯示在窗口的頂部欄上? 謝謝
您可以使Example_Page公開表示標題的屬性(例如Title
),然后使FrameWindow Title屬性綁定到該屬性。 一個例子:
在FrameWindow
的標記中,像這樣綁定標題:
<Window ...
Title="{Binding Content.Title, RelativeSource={RelativeSource Self}}">
並且在您的Example_Page代碼后面公開了這樣的屬性:
public partial class Example_Page : ....
{
...
public string Title { get; set; }
...
}
請注意,如果將FrameWindow的Content設置為任何不公開此屬性的內容,則Title將為空白。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.