views:

247

answers:

0

I'm trying to visualize a XAML resource file at design time. When I merge the dictionary for the following XAML resource file into a XAML Window I get the error: Could not create an instance of type 'GlyphTypeface'.

The problem line is:

<GlyphTypeface FontUri="C:\WINDOWS\Fonts\TAHOMA.TTF" />

I have verified that the font exist in the system at that path, so no problem with that. However it seems like the window designer can't instantiate the GlyphTypeface at design time. Very frustrating because I can't view the graphical output. I need to make this work as it is so I can't change GlyphTypeface tag for Font tag. Thanks for help...

Here is the full XAML definition:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cd="clr-namespace:DiagramDesigner;assembly=DiagramDesigner">
<!-- Full Adder -->
<DrawingGroup x:Key="FADrawingResource">
    <DrawingGroup.Children>
        <GeometryDrawing>
            <GeometryDrawing.Geometry>
                <GeometryGroup>
                    <GeometryGroup>
                        <RectangleGeometry Rect="0,0,50,60"/>
                    </GeometryGroup>
                </GeometryGroup>
            </GeometryDrawing.Geometry>
            <GeometryDrawing.Pen>
                <Pen Thickness="1" Brush="Black"/>
            </GeometryDrawing.Pen>
        </GeometryDrawing>

        <GlyphRunDrawing ForegroundBrush="Black">
            <GlyphRunDrawing.GlyphRun>
                <GlyphRun 
                    GlyphIndices="36" 
                    BaselineOrigin="2.5,13"  
                    FontRenderingEmSize="12" 
                    AdvanceWidths="0" 
                    >
                    <GlyphRun.GlyphTypeface>
                        <GlyphTypeface FontUri="C:\WINDOWS\Fonts\TAHOMA.TTF" />
                    </GlyphRun.GlyphTypeface>
                </GlyphRun>
            </GlyphRunDrawing.GlyphRun>
        </GlyphRunDrawing>

    </DrawingGroup.Children>
</DrawingGroup>