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 6594973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:52:46+00:00 2026-05-25T17:52:46+00:00

I have an XAML tree as follows: <Window> <Grid> <DockPanel> <DataGrid> <DataGrid.Resources> <CheckBox Command={Binding

  • 0

I have an XAML tree as follows:

<Window>
    <Grid>
        <DockPanel>
               <DataGrid>
                      <DataGrid.Resources>
                              <CheckBox Command="{Binding Command}" CommandParameter="??" />
                      </DataGrid.Resources>
               </DataGrid>
              <StackPanel>
                    <ChartLegend>
                    </ChartLegend>
                    <DataChart>
                    </DataChart>
              </stackPanel>
        </DockPanel>
    </Grid>
</Window>

I want to have DataChart object as CommandParameter on ViewModel from a Command on DataGrid.

My Findings:

I’m getting DockPanel object as CommandParameter, then I have to apply method FindName("") to get the DataChart. And do further modifications.

But I want the DataChart object directly, to avoid TypeCasting or searching down the Tree.

  • 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-25T17:52:47+00:00Added an answer on May 25, 2026 at 5:52 pm

    You can keep datachart as a named resource in your DockPanel resources and use static resource binding to command parameter. Then use ContentControl to host it.

    like this…

        <DockPanel>
                <DockPanel.Resources>
                     <DataChart x:Key="MyDataChart">
                     </DataChart>
                </DockPanel.Resources>
                <DataGrid>
                       <DataGrid.Resources>
                               <CheckBox 
                                     Command="{Binding Command}"
                                     CommandParameter="{StaticResource MyDataChart}" />
                       </DataGrid.Resources>
                </DataGrid>
               <StackPanel>
                     <ChartLegend>
                     </ChartLegend>
                     <ContentControl Content="{StaticResource MyDataChart}"/>
               </stackPanel>
         </DockPanel>
    

    Hoping that you wont use same MyDataChart to host to another area (as that would result in “visual tree parent disconnect” error).

    Although I must ask you this… why is there a lonely CheckBox in your DataGrid resources?

    Also your’s and mine solution breaks MVVM because we are supplying a UI control (Chart control) to a View Model.

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

Sidebar

Related Questions

I have a .xaml file and a .cs file that share value with Binding.
I have this XAML: <Window x:Class=WpfBindToCodeBehind.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Window1 Height=300 Width=300 Loaded=Window_Loaded> <StackPanel Orientation=Vertical>
I have a XAML window with multiple TextBoxes, each with a corresponding TextBlock tag
I have a xaml code: <Grid> <WrapPanel> <TextBox ></TextBox> <Button Content=GetIt /> </WrapPanel> </Grid>
I have some XAML <ItemsControl Name=mItemsControl> <ItemsControl.ItemTemplate> <DataTemplate> <TextBox Text={Binding Mode=OneWay} KeyUp=TextBox_KeyUp/> </DataTemplate> </ItemsControl.ItemTemplate>
I have a XAML based ContextMenu bound to the rows in a datagrid. It
I have a window with a tree view control inside and a XML file.
Below is the XAML i currently have. I want to emulate a tree by
I have a MainWindow that contains a window with a TreeView. The tree view
I have in my Xaml a pivot control : <controls:Pivot ItemsSource={Binding ObjectList}> <controls:Pivot.HeaderTemplate> <DataTemplate>

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.