Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 Windows Phone 7:找不到全局资源_Windows Phone 7_Datatemplate_Styles_Resourcedictionary_Windows Phone - Fatal编程技术网

Windows phone 7 Windows Phone 7:找不到全局资源

Windows phone 7 Windows Phone 7:找不到全局资源,windows-phone-7,datatemplate,styles,resourcedictionary,windows-phone,Windows Phone 7,Datatemplate,Styles,Resourcedictionary,Windows Phone,我正在尝试使用全局资源字典,但在尝试使用它包含的样式时出错。在我的app.xaml中,我有: <Application.Resources> <ViewModel:ViewModelLocator x:Key="Locator" d:IsDataSource="True" /> <ResourceDictionary x:Key="dict1">

我正在尝试使用全局资源字典,但在尝试使用它包含的样式时出错。在我的app.xaml中,我有:

 <Application.Resources>
        <ViewModel:ViewModelLocator x:Key="Locator"
                             d:IsDataSource="True" />
        <ResourceDictionary x:Key="dict1">
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/ListBox.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>

在/Themes/ListBox.xaml中,我有:

<Style x:Key="CategoryListTemplate" TargetType="ListBox">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="SelectionMode" Value="Extended" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Margin" Value="2" />
                    <Setter Property="Template">
            ....

....
我正在尝试设置以下样式:

<ListBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" x:Name="lstCategories" SelectionMode="Extended" Style="{StaticResource CategoryListTemplate}" ...
请参阅


手机似乎不支持以这种方式合并词典。

我用App.xaml.cs中的以下内容解决了这个问题:

var dictionaries = Resources.MergedDictionaries;
            dictionaries.Clear();
            var dicts = new[]{
                "/ChickenPing.Mobile;component/Themes/ThemeResources.xaml",
                "/ChickenPing.Mobile;component/Themes/generic.xaml",
                "/ChickenPing.Mobile;component/Themes/ListBox.xaml",
                "/ChickenPing.Mobile;component/Themes/Rating.xaml",
                "/ChickenPing.Mobile;component/Themes/CheckBox.xaml",
        };
            foreach (var dict in dicts) {
                var themeStyles = new ResourceDictionary {Source = new Uri(dict, UriKind.Relative)};
                dictionaries.Add(themeStyles);
            }