xaml error message

akohan
akohan used Ask the Experts™
on
hello group,

I am working on a xaml file (WPF) and keep running into this error message.

{"'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '6' and line position '9'."}


<Window x:Class="myproject.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStartupLocation="CenterScreen"
        Title="MainWindow" 
        Height="850" Width="1000">

Open in new window


What is causing this? I'm using default xml name spaces. I will appreciate it if you let me know.


Thanks,
amit
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
please provide complete xaml.

Author

Commented:
Sure. here is the xaml file I'm getting error as:
 
'Provide value on 'System.Windows.StaticResourceExtension' threw an exception.' Line number '22' and line position '10'.

<Window x:Class="akohan.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:akohan"
        xmlns:c="clr-namespace:akohan.Controls"
        WindowStartupLocation="CenterScreen"
        Title="MainWindow" 
        Height="850" Width="1000">
   
    <Window.Resources>
        <ContextMenu x:Key="DesignerCanvasContextMenu">
            <MenuItem Header="Paste" Command="{x:Static ApplicationCommands.Paste}">
                <MenuItem.Icon>
                    <Image Source="/akohan;component/Resources/image/Paste.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Select All" Command="{x:Static s:DesignerCanvas.SelectAll}"/> 
        </ContextMenu>
    </Window.Resources>

    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <ContentControl Content="{StaticResource MyToolbar}"/>

            <Grid Grid.Row="1" Margin="0,10,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="265"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <!-- Toolbox -->
            <StackPanel Grid.Column="0" Margin="0,0,5,0">
                <Expander Header="set 1" IsExpanded="True"/>
                <Expander Header="set 2" Content="{StaticResource ShapeStencils}" IsExpanded="True"/>
            </StackPanel>
            <!-- GridSplitter-->
            <GridSplitter Focusable="False" Width="2" Background="LightGray" VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
            <!-- Designer -->
            <GroupBox Header="Canvas" Grid.Column="1" Margin="3,0,0,0">
                <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                    <s:DesignerCanvas Focusable="True" x:Name="MyDesigner" Background="{StaticResource windowBackgroundBrush}" Margin="10" FocusVisualStyle="{x:Null}" ContextMenu="{StaticResource DesignerCanvasContextMenu}" />
                    
                </ScrollViewer>
            </GroupBox>
            
            
        </Grid>
    </Grid>
</Window>

Open in new window

Aaron JabamaniTechnical Architect

Commented:
For static resource, you should define it before reference to it (dynamic resource doesn't have this limitation). you could place the resources "MyToolbar" in the Resources section of the Window (Window.xaml) or the application (App.xaml).
Announcing the Winners!

The results are in for the 15th Annual Expert Awards! Congratulations to the winners, and thank you to everyone who participated in the nominations. We are so grateful for the valuable contributions experts make on a daily basis. Click to read more about this year’s recipients!

Author

Commented:
Thanks Apeter,

Can you tell me how I can do that? any link that discusses it? something that will walk me step by step.


Thanks.

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial