2014-06-06 3 views
3

리소스의 Appbar에 사용하고있는 버튼에 FontIcons를 넣으려고합니다. 코드는 다음과 같습니다 :Universal App의 리소스에서 FontIcon을 사용할 때 XamlParseException

<Page.Resources> 
    <FontFamily x:Key="IconsFont">/Assets/iconfont.ttf#iconfont</FontFamily> 
    <FontIcon x:Key="LogoutIcon" FontFamily="{StaticResource IconsFont}" Glyph="&#xe600;" FontSize="35" /> 
    </Page.Resources> 
<Page.BottomAppBar> 
    <CommandBar> 
    <AppBarButton Icon="Find" Label="search" Command="{Binding SearchCommand}" Visibility="{Binding SearchCommandVisibility}"/> 
    <AppBarButton Label="logout" Command="{Binding LogoutCommand}" Icon="{StaticResource LogoutIcon}" /> 
    </CommandBar> 
</Page.BottomAppBar> 

디자이너 모두보기에는 아이콘이 올바르게 표시됩니다. 그러나 응용 프로그램을 시작할 때 일반 오류 텍스트가있는 XamlParseException이 발생합니다. " '% 0'속성에 할당하지 못했습니다."

자원에서 FontIcon을 제거하면 제대로 작동합니다.

아이디어가 있으십니까?

답변

1

보십시오, 페이지 리소스에서

<Page.BottomAppBar> 
    <CommandBar> 
     <AppBarButton Icon="Find" Label="search"/> 
     <AppBarButton Label="logout"> 
      <AppBarButton.Icon> 
       <FontIcon FontFamily="{StaticResource IconsFont}" Glyph="&#xe600;" FontSize="35"/> 
      </AppBarButton.Icon> 
     </AppBarButton> 
    </CommandBar> 
</Page.BottomAppBar> 

그리고 제거 <FontIcon x:Key="LogoutIcon" FontFamily="{StaticResource IconsFont}" Glyph="&#xe600;" FontSize="35" />.

+0

이 방법이 효과가 있지만 필요한 것은 아닙니다. 아이콘을 자원에 보관해야합니다. –