Preloading External Resources and/or Styles RRS feed

  • Question

  • I have several resources located in other projects that I want to use in another project. However, when I try to do this, I get errors during runtime when I navigate to page containing the control that uses the resources (which are Styles). If I remove the Styles from the control (by getting rid of the Style attribute), everything is fine (except that my control does not look the way I want). Based on everything I could find, this is because the control is attempting to use the resources before they are loaded. However, I have been unable to find a way to explicitly load the resources beforehand. Is there any way to force my control to load the resources before attempting to use them? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Saturday, February 7, 2015 9:09 PM

All replies

  • Hi,

    How do you use the external resource? Please share a reproduce sample for us. As far as I know, In windows store app,you have to use ms-appx for Resource dictionaries in dlls. The Build Action should be Page.


    If you have a dll named "CustomControl" with a ResourceDictionary named "Styles.xaml", the App.xaml should contain

                    <ResourceDictionary Source="ms-appx:///CustomControls/Styles.xaml"/>

    Best Wishes!

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    • Edited by Anne Jing Monday, February 9, 2015 7:52 AM edit
    Monday, February 9, 2015 6:31 AM
  • I use the external resource in a control that is in a Portable Class Library, which means that there is no App.xaml. The control is in a Portable Class Library because I am creating a Universal App. The control actually inherits from ItemsControl rather than UserControl. Is this causing a problem? Here is the XAML for the control:
    	xmlns:app="using:UniversalAppExtras" mc:Ignorable="d">
    				<ResourceDictionary Source="ms-appx:///UniversalAppExtras/NoDeleteTextBox.xaml"/>
    				<ResourceDictionary Source="ms-appx:///UniversalAppExtras/BasicButton.xaml"/>
    					<app:IsNullOrWhiteSpaceConverter x:Key="IsNullOrWhiteSpace"/>
    					<app:HideValueOpacityConverter x:Key="HideValueOpacity"/>
    			<Grid x:Name="grdPlayerTemplate" Loaded="grdPlayerTemplate_Loaded">
    					<ColumnDefinition Width="*"/>
    					<ColumnDefinition Width="Auto"/>
    					<ColumnDefinition Width="Auto"/>
    				<TextBox Grid.Column="0" Style="{StaticResource NoDeleteTextBox}" FontSize="32" Margin="0,3" Padding="3,-6" Text="{Binding PlayerName}" Tag="{Binding Index}" BorderThickness="1" BorderBrush="Black" VerticalAlignment="Stretch" IsTextPredictionEnabled="False" TextChanged="PlayerName_TextChanged" Loaded="PlayerName_Loaded" GotFocus="PlayerName_GotFocus"/>
    				<Button Grid.Column="1" Style="{StaticResource BasicButton}" FontSize="32" Margin="3,1.5" Padding="0,-2,1,-1" Content="&#xE10A;" Tag="{Binding Index}" FontFamily="Segoe UI Symbol" IsEnabled="{Binding Children[0].Text,ElementName=grdPlayerTemplate,Converter={StaticResource IsNullOrWhiteSpace},ConverterParameter=NOT}" Click="DeletePlayer_Click"/>
    				<Button Grid.Column="2" Style="{StaticResource BasicButton}" FontSize="32" Margin="0,1.5" Padding="8,1,8,2" Content="Move Up" Tag="{Binding Index}" IsEnabled="{Binding Children[0].Text,ElementName=grdPlayerTemplate,Converter={StaticResource IsNullOrWhiteSpace},ConverterParameter=NOT}" Opacity="{Binding Index,Converter={StaticResource HideValueOpacity}}" Click="MoveUp_Click"/>
    Is there something wrong with this code that is causing it to not load? Is there something I need to add? Thanks.

    Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

    Monday, February 9, 2015 4:49 PM