Exception: 이름이 'BaseTextBlockStyle’인 리소스를 찾을 수 없습니다. (From Texts.xaml)
사전 병합 후 리소스를 찾 을 수 없습니다.( BasedOn=“{StaticResource BaseTextBlockStyle}”)
<!-- Button.xaml -->
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- 사전병합 => Texts.xaml -->
<ResourceDictionary Source="Texts.xaml" />
</ResourceDictionary.MergedDictionaries>
...
<Style x:Key="LoginButton1" TargetType="{x:Type Button}" BasedOn="{StaticResource BaseStyle}">
<Setter Property="local:IsBusyProperty.Value" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<Border x:Name="border"
...
<Grid>
<TextBlock Focusable="False"
Visibility="{TemplateBinding local:IsBusyProperty.Value, Converter={local:BooleanToVisiblityConverter}}"
Text="{TemplateBinding Content}"
FontFamily="{TemplateBinding FontFamily}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<!-- Texts.xaml에서 정의한 TextBlock Style을 참조 -->
<TextBlock Style="{StaticResource SpinningText}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{TemplateBinding local:IsBusyProperty.Value, Converter={local:BooleanToVisiblityConverter}, ConverterParameter=True}"
/>
....
<!-- Texts.xaml -->
<Style TargetType="{x:Type TextBlock}" x:Key="SpinningText" BasedOn="{StaticResource BaseTextBlockStyle}">
<Setter Property="FontFamily" Value="{StaticResource FontAwesome}" />
<Setter Property="Text" Value="" />
<Setter Property="RenderTransformOrigin" Value="0.5, 0.5" />
<Setter Property="RenderTransform">
<Setter.Value>
<RotateTransform></RotateTransform>
</Setter.Value>
</Setter>
<Style.Resources>
<Storyboard x:Key="Spin">
<DoubleAnimation
Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)"
From="0"
To="360"
Duration="0:0:2"
RepeatBehavior="Forever" />
</Storyboard>
</Style.Resources>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=IsVisible}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Name="SpinStoryboard" Storyboard="{StaticResource Spin}" />
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="SpinStoryboard" />
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
버튼에 대한 스타일, TextBlock에 관한 스타일을 서로다른 xaml에 나눠서 만들었습니다.
Ex) Button.xaml => ‘Style TargetType = button’
Texts.xaml => '‘Style TargetType = TextBlock’
Button.xaml에서 Text.xaml을 사전병합하고
Button style의 TextBlock부분에서 TextBlock 스타일을 참조합니다.
로그인 버튼을 만들고 대기시간 동안 로그인 버튼에 스피너가 돌아가게 만드는 중입니다.
"IsBusyProperty"로 로그인 중인지 파악하고
로그인 중이라면 버튼의 Text가 스피너 모양으로 변하는 것까지 했습니다.
그 뒤 스피너에 애니메이션을 추가하고 사전병합을 진행 했는데 오류가 나네요.
사전 병합시 StaticResource를 사용할 수 없다는데 맞나요?
깃허브 : [저장소]