나는 DataTemplate
을 정의하려고하고 있는데, 그 안에는 Button
의 스타일을 설정하고 싶습니다. 현재 내가 몇 가지 코드를 보여 ... 아마 더 나은 MergedDictionaries
와 UserControl
있습니다데이터 템플릿 내에서 다른 사전의 정적 리소스를 사용할 수 있습니까?
<UserControl.Resources>
<ResourceDictionary.MergedDictionaries>
<!-- MyButtonStyle is in this dictionary -->
<ResourceDictionary Source="ms appx:///Dictionaries/ButtonStyles.xaml"/>
<ResourceDictionary>
<DataTemplate x:Key="MyDataTemplate">
<Grid>
<!-- Here is the button I want to apply the style to -->
<Button Style="{StaticResource MyButtonStyle}"/>
</Grid>
</DataTemplate>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</UserControl.Resources>
내가 DataTemplate
내 ButtonStyles.xaml
에 위치한 MyButtonStyle
에 내부 Button
의 스타일을 설정합니다. 하지만 다음과 같은 오류가 나타납니다 :
Resource `MyButtonStyle` is not found
예제에서 내 리소스를 올바르게 참조하려면 어떻게합니까?
사전을 응용 프로그램의 리소스로 옮길 수 있습니까? – JohnyL
이 시점에서 우리는 실제로 그렇게 할 수 없습니다. – visc
그 냄새. 그래서 우리를위한 유일한 해결책은 스타일을 로컬 리소스 사전에 직접 복사하는 것입니다. – visc