0

でデータテンプレートを取得しました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ます。

4

1 に答える 1

2

次のようにResourceDictionnaryタグを使用して、mainPage.xaml から resources.xaml への参照を追加する必要があります。

<Window x:Class="MainPage"  ...  ... >
     <Window.Resources>
         <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/YourProjectDLL;component/Resource.xaml" />
            </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
     </Window.Resources>
     <Grid>
          ... Your window body
     </Grid>
</Window>
于 2015-11-26T14:37:33.093 に答える