none
DocumentViewer ControlTemplate Error RRS feed

  • Frage

  • Hallo,

    wenn ich den folgenden Code in die Window.Resources einfüge:

    <Style x:Key="{x:Type DocumentViewer}" TargetType="DocumentViewer">
    <Setter Property="Foreground"
             Value="Black"/>
    <Setter Property="Background"
             Value="White"/>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="ContextMenu"
             Value="{DynamicResource {ComponentResourceKey
             TypeInTargetAssembly={x:Type ui:PresentationUIStyleResources},
             ResourceId=PUIDocumentViewerContextMenu}}"/>
    <Setter Property="Template">
        <Setter.Value>
         <ControlTemplate TargetType="DocumentViewer">
            <Border BorderThickness="{TemplateBinding BorderThickness}"
                    BorderBrush="Black" Focusable="False">
             <Grid Background="White"
                KeyboardNavigation.TabNavigation="Local">
                <Grid.RowDefinitions>
                 <RowDefinition Height="Auto"/>
                 <RowDefinition Height="*"/>
                 <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <ToolBar
                 ToolBarTray.IsLocked="True"
                 KeyboardNavigation.TabNavigation="Continue">
                 <Button Command="ApplicationCommands.Print"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    Content="Print"/>
                 <Button Command="ApplicationCommands.Copy"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    Content="Copy"/>
                 <Separator />
                 <Button Command="NavigationCommands.IncreaseZoom"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    Content="Zoom In"/>
                 <Button Command="NavigationCommands.DecreaseZoom"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    Content="Zoom Out"/>
                 <Separator />
                 <Button Command="NavigationCommands.Zoom"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    CommandParameter="100.0"
                    Content="Actual Size" />
                 <Button Command="DocumentViewer.FitToWidthCommand"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    Content="Fit to Width" />
                 <Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    CommandParameter="1"
                    Content="Whole Page"/>
                 <Button Command="DocumentViewer.FitToMaxPagesAcrossCommand"
                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                    CommandParameter="2"
                    Content="Two Pages"/>
                </ToolBar>

                <ScrollViewer Grid.Row="1"
                 CanContentScroll="true"
                 HorizontalScrollBarVisibility="Auto"
                 x:Name="PART_ContentHost"
                 IsTabStop="true"/>

                <ContentControl Grid.Row="2"
                 x:Name="PART_FindToolBarHost"/>
             </Grid>
            </Border>
         </ControlTemplate>
        </Setter.Value>
    </Setter>
    </Style>

    so erhalte ich im Designer die Ausnahme:

    "Zoom" ist kein gültiger Wert für die Eigenschaft "Command".

    Dies ist nur bei Zoom so. Wenn ich das Programm starte, läuft es einwandfrei und auch der Zoombefehl tut seinen Dienst. Nur der Fehler im Designer bleibt. Und somit kann der Designer nicht per Drag and Drop genutzt werden..

    Mache ich etwas falsch?

     

    MfG

    Donnerstag, 10. Juni 2010 19:49

Alle Antworten