2017-01-30 3 views
0

나는 FontAwesome 아이콘으로 햄버거 메뉴를 다시 채우려고하고 있는데, 내 방식은 내 응용 프로그램의 ResourseDictionoary입니다. 이제 문자 모양을 위해 FontAwesomeUserString 키를 바인딩하고 싶습니다. 개체의 내 속성은 string 유형의 아이콘입니다. 내 목록에 x:DataType="local:MenuItem"의 Icon 변수에는 my resoursedictionary의 값이 있습니다.바인딩 StaticResourse Key in uwp

<FontIcon Grid.Column="0" FontFamily="{StaticResource FontAwesomeFontFamily}" Glyph="{StaticResource FontAwesomeUserString}" Foreground="White" /> 
<TextBlock Grid.Column="1" Text="{x:Bind Name, Mode=OneWay}" TextWrapping="Wrap" FontSize="16" VerticalAlignment="Center" Foreground="White"/> 

StaticResourse의 ResourceKey 속성을 바인딩 할 수 있는지 여부를 알려주십시오. 는

+0

리소스 코드도 게시해야합니다. 당신이 여기 제대로하고 있어요. {StaticResource}가 {Binding}과 다른 점을 기억해주세요.하지만 지금하고있는 일에 대해 올바른 것으로 보입니다. –

+0

안녕하세요 @MichaelPuckettII. 답변 해주셔서 감사합니다. 소스 코드 [here] (https://github.com/amoraitis/AuebUnofficial/blob/Dev/AuebUnofficial/Helpers/HandlingUI/FontAwesomeDictionary.xaml)를 찾을 수 있습니다. 정적 리소스가 코드의 모든 값을 가져 오길 원합니다. [behind] (https://github.com/amoraitis/AuebUnofficial/blob/Dev/AuebUnofficial/Navig.xaml.cs) 여기 내 코드는 [xaml] (https://github.com/amoraitis/AuebUnofficial/)입니다. blob/Dev/AuebUnofficial/Navig.xaml) –

+0

감사 Anastasios. 하나; 아래 빈센트는 질문에 답해주었습니다. 그곳에서 무슨 말을했는지 살펴 보겠습니다. –

답변

1

당신은 다음과 같은 코드를 통해 대체하여 리소스 사전의 값을 변경할 수 있습니다 감사합니다

Application.Current.Resources["FontAwesomeUserString"] = "&glyphCode"; 

페이지가 생성 될 때 StaticResource는 읽기 전용 잊지 마세요.

사전을 업데이트 할 때마다 충분할 수도 있지만 리소스 사전에서 무언가를 변경할 때 응용 프로그램이 올바르게 업데이트되기를 원하면 ThemeResource을 사용해야합니다.

ThemeResourcehere에 대한 자세한 내용을 볼 수 있습니다.

<FontIcon Grid.Column="0" 
    FontFamily="{ThemeResource FontAwesomeFontFamily}" 
    Glyph="{ThemeResource FontAwesomeUserString}" 
    Foreground="White" /> 

업데이트

그냥 모든 항목에 대한 그래프/폰트 패밀리를 설정하려는 경우, 일반 바인딩은 충분하다 :

<DataTemplate x:Key="DefaultTemplate" x:DataType="local:MenuItem"> 
     <Grid Width="240" Height="48"> 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="48" /> 
       <ColumnDefinition Width="*"/> 
      </Grid.ColumnDefinitions> 

      <FontIcon Grid.Column="0" FontFamily="{x:Bind FontFamily}" Glyph="{x:Bind Icon}" Foreground="White" /> 
      <TextBlock Grid.Column="1" Text="{x:Bind Name, Mode=OneWay}" TextWrapping="Wrap" FontSize="16" VerticalAlignment="Center" Foreground="White"/> 
     </Grid> 
    </DataTemplate>   

당신은 단지를 정의해야 보기 모드에서 FontFamilyIcon el UWP 툴킷에서 햄버거 메뉴를 볼 수 있습니다 documentation

+0

답장을 보내 주셔서 감사합니다. 바인딩을 위해 [this like] (http://prnt.sc/e2d5u1) 개체에서 어떻게 구현할 수 있는지 알 수 없습니다. 다른 가치관을 원해. 뿐만 아니라 'FontAwesomeUserString'값. –