2016-07-13 9 views
7

UWP에서 TitleBar (창)에 아이콘을 설정하는 방법은 무엇입니까? 제목 표시 줄 아이콘의UWP에서 TitleBar 아이콘을 설정하는 방법은 무엇입니까?

예 : 우리는 제목 표시 줄의 아이콘을 설정하는 제목 표시 줄을 사용자 정의 할 수 있습니다

+0

다음 중 하나를 선택하십시오. http://www.codezero.one/Details?d=1507&a=9&f=191&l=0&v=d&t=Win10-Sample:- Title-bar-sample –

답변

9

. 요점은 Window.SetTitleBar method입니다. 다음은 간단한 샘플입니다.

먼저 새 제목 표시 줄에 UIElement이 필요합니다. 예를 들어 MainPage.xamlGrid을 추가하고 그리드에 아이콘과 응용 프로그램 이름을 설정할 수 있습니다. 우리는 "TitleBar"Grid을 루트 그리드의 첫 번째 행에 넣어야합니다.

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 

    <Grid x:Name="TitleBar"> 
     <Rectangle x:Name="BackgroundElement" Fill="Transparent" /> 
     <Grid> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto" /> 
       <ColumnDefinition Width="Auto" /> 
      </Grid.ColumnDefinitions> 
      <Image Height="32" Margin="5,0" Source="Assets/StoreLogo.png" /> 
      <TextBlock Grid.Column="1" VerticalAlignment="Center" Text="My Application" /> 
     </Grid> 
    </Grid> 
</Grid> 

그런 다음 MainPage.xaml.cs를, 우리는 아이콘으로 새로운 제목 표시 줄을 설정하려면 다음 코드를 사용할 수 있습니다. 사용자 정의 샘플에 그리기 :

public MainPage() 
{ 
    this.InitializeComponent(); 

    CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; 
    // Set the BackgroundElement instead of the entire Titlebar grid 
    // so that we can add clickable element in title bar. 
    Window.Current.SetTitleBar(BackgroundElement); 
} 

는 더 많은 정보를 들어, 특히 시나리오 2, GitHub의에 공식 Title bar sample를 참조 할 수 있습니다.