でデータテンプレートを取得しましたResource.xaml
:
<DataTemplate x:Key="SplitViewMenuItemWithCount">
<RelativePanel>
<RelativePanel RelativePanel.AlignVerticalCenterWithPanel="True" Margin="0,10,0,10">
<SymbolIcon Foreground="White" Width="25" RelativePanel.AlignVerticalCenterWithPanel="True" Symbol="{Binding Symbol}" x:Name="SymbolIcon" Margin="10,0,0,0"/>
<StackPanel Visibility="{Binding Count, Converter={StaticResource BooleanToVisibilityConverter}, TargetNullValue=Collapsed, FallbackValue=Collapsed}" x:Name="StackPanelCount" RelativePanel.RightOf="SymbolIcon" Margin="0,20,0,0" CornerRadius="9" Background="White" Width="15" Height="15">
<TextBlock Text="{Binding Count, FallbackValue='0'}" TextAlignment="Center" FontSize="10" Foreground="{StaticResource AppDarkBlueColor}"/>
</StackPanel>
<TextBlock Margin="10,0,0,0" Foreground="White" x:Name="TextBlockMenuItemText" RelativePanel.RightOf="StackPanelCount" Text="{Binding Text}" FontSize="16" Padding="5,3,0,5"/>
</RelativePanel>
</RelativePanel>
</DataTemplate>
MainPage.xaml のデータ テンプレートを ListView のデータ テンプレートとして使用していますが、BooleanToVisibilityConverter
. でコンバーターが見つかりませんResource.xaml
。
ただし、データテンプレートを自分に配置するとMainPage.Resources
、コンバーターが見つかります (そこで定義されているため)。
データテンプレートを保持する方法はありますResource.xaml
か? 私はむしろそこにそれを持っていMainPage.Resources
ます。