Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:30:51+00:00 2026-05-27T19:30:51+00:00

I have the following Style for a DocumentViewer: <Style x:Key=MyDocumentViewerStyle TargetType={x:Type DocumentViewer}> <Setter Property=Foreground

  • 0

I have the following Style for a DocumentViewer:

<Style x:Key="MyDocumentViewerStyle" TargetType="{x:Type DocumentViewer}">
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type DocumentViewer}">
                <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Focusable="False">
                    <Grid KeyboardNavigation.TabNavigation="Local">
                        <Grid.Background>
                            <SolidColorBrush Color="{DynamicResource ControlLightColor}" />
                        </Grid.Background>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Border Grid.Row="1" CornerRadius="2" HorizontalAlignment="Stretch" BorderThickness="0">
                            <ToolBar HorizontalAlignment="Center" Height="35"
                                     ToolBarTray.IsLocked="True" KeyboardNavigation.TabNavigation="Continue" ToolBar.OverflowMode="Never">
                                <Button Command="ApplicationCommands.Print" Margin="10,0"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <!--Content="Print">-->
                                    <Image Source="/ApniCureConsole;component/Images/Print.png" ToolTip="Print report" />
                                </Button>
                                <Separator />
                                <Button Command="NavigationCommands.IncreaseZoom" Margin="10,0"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <!--Content="Zoom In">-->
                                    <Image Source="/ApniCureConsole;component/Images/MagnifyPlus.png" ToolTip="Zoom in" />
                                </Button>
                                <Button Command="NavigationCommands.DecreaseZoom" Margin="10,0"
                                    CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                    <!--Content="Zoom Out" />-->
                                    <Image Source="/ApniCureConsole;component/Images/MagnifyMinus.png" ToolTip="Zoom out" />
                                </Button>
                                <Separator />
                                <Button Margin="10,0,10,0"
                                        Content="SAVE REPORT"
                                        ToolTip="Save the report"
                                        Style="{StaticResource CommandButton}"
                                        Command="{Binding Path=SaveReportCommand}"
                                        CommandParameter="{Binding ????}"   <------WHAT DO I PUT HERE?
                                        CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"/>
                            </ToolBar>
                        </Border>

                        <ScrollViewer Grid.Row="0" CanContentScroll="true" HorizontalScrollBarVisibility="Auto" x:Name="PART_ContentHost" IsTabStop="true">
                            <ScrollViewer.Background>
                                <LinearGradientBrush EndPoint="0,0" StartPoint="0,1">
                                    <GradientStop Color="#559CB7A4" Offset="0" />
                                    <GradientStop Color="White" Offset="1" />
                                </LinearGradientBrush>
                            </ScrollViewer.Background>
                        </ScrollViewer>
                    </Grid>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

I’ve defined the following elements in my application that use this Style:

<TabControl Style="{StaticResource MyTabControlStyle}" TabStripPlacement="Top" >
    <TabItem Style="{StaticResource MyTabItemStyle}" IsTabStop="False">
        <TabItem.Header>
            <TextBlock Text="REPORT ONE" Height="18" Padding="10, 0" FontSize="14" Style="{StaticResource MyTabItemText}"/>
        </TabItem.Header>
        <DocumentViewer Name="ReportOne" IsTabStop="False" Document="{Binding Report1}" ContextMenu="{x:Null}" Style="{StaticResource MyDocumentViewerStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="#FF00668E">
        </DocumentViewer>
    </TabItem>
    <TabItem Style="{StaticResource MyTabItemStyle}" IsTabStop="False">
        <TabItem.Header>
            <TextBlock Text="REPORT TWO" Height="18" Padding="10, 0" FontSize="14" Style="{StaticResource MyTabItemText}"/>
        </TabItem.Header>
        <DocumentViewer Name="ReportTwo" IsTabStop="False" Document="{Binding Report2}" ContextMenu="{x:Null}" Style="{StaticResource MyDocumentViewerStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0" BorderBrush="#FF00668E">
        </DocumentViewer>
    </TabItem>
</TabControl>

My question is, how can I find out what the value for the “Name” property is from the XAML, so I can pass it my ViewModel?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:30:52+00:00Added an answer on May 27, 2026 at 7:30 pm

    Assuming that you want to pass the Name of the DocumentViewer as the CommandParameter to the ViewModel, the easiest is to use

    CommandParameter="{TemplateBinding Name}"
    

    which will bind the name of the templated control to the CommandParameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following wpf: <Style x:Key=HyperlinkStyle TargetType=Hyperlink> <Setter Property=Foreground Value={StaticResource {x:Static SystemColors.ControlTextBrushKey}}/> <Setter Property=TextDecorations
I have the following style: <Style x:Key=ActionLabelStyle TargetType={x:Type Label}> <Setter Property=Margin Value=10,3 /> <Setter
I have following style in a xaml file: <Style x:Key=LabelText TargetType=TextBlock> <Setter Property=FontFamily Value=Segoe
In <Window.Resources> I have defined following style: <Style x:Key=textBlockStyle TargetType=TextBlock> <Setter Property=Margin Value=5,0,5,0/> </Style>
<Style x:Key=FavouriteMenuItemStyle TargetType={x:Type MenuItem} BasedOn={StaticResource BasicFavouriteItemStyle}> <Setter Property=Width Value=Auto/> <Setter Property=Template> <Setter.Value> <ControlTemplate TargetType={x:Type
I have the following style defined in my App.xaml <Style x:Key=textBoxMultiline TargetType={x:Type TextBox} >
I have the following style defined... <!-- Blue Button --> <Style x:Key=BlueButton TargetType={x:Type Button}>
I have a ToggleButton to which I'm applying the following style <Style x:Key=ToggleButtonStyle TargetType=ToggleButton>
In my application, I have defined the following style for TextBlocks. <Style TargetType={x:Type TextBlock}>
I have applied the following style to the CalendarStyle property of DatePicker: <Style x:Key=myStyle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.