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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:08:13+00:00 2026-05-16T09:08:13+00:00

Simple case: <usercontrol> <Views:UserListView x:Name=settingsTreeView/> <Button DataContext={Binding ElementName=settingsTreeView, Path=SelectedItem} Command={Binding CreateChildCommand}/> </usercontrol> The task

  • 0

Simple case:

<usercontrol>
   <Views:UserListView x:Name="settingsTreeView"/>
   <Button DataContext="{Binding ElementName=settingsTreeView, Path=SelectedItem}"
           Command="{Binding CreateChildCommand}"/>
</usercontrol>

The task just is to bind to button a DataContext which implements CreateChildCommand.
DataContext is the selected item in the treeview.
Nothing to happen.
I have checked the button properties at run time: both Command and DataContext properties of the button are null.

Questions:

  1. Is it valid to change DataContext at runtime?
  2. How to pass selected item to the Command object?

Concerning commanding in Silverlight you can refer to:

http://johnpapa.net/silverlight/5-simple-steps-to-commanding-in-silverlight/
http://community.infragistics.com/silverlight/media/p/125526.aspx

http://houseofbilz.com/archives/2009/05/22/adventures-in-mvvm-commands-in-silverlight/
http://www.silverlightshow.net/items/Silverlight-4-How-to-Command-Control.aspx

something goes wrong

  • 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-16T09:08:14+00:00Added an answer on May 16, 2026 at 9:08 am

    First thing to do would be to check if your bindings are failing. You should see some sort of output in the output log if this is the case. Its valid to change the DataContext at runtime, and you can bind the selected item to the CommandParameter property on the button if you want it to be passed to the command. Let me know if you have errors in your output log or not.

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

Sidebar

Related Questions

Simple case: I want to load several images which have a common name and
This is a very simple case I want to click on the button, then
Simple case of trying to prove I can convert NSString to NSDate . Create
Imagine a simple case like this: class Book has_many :chapters end Let's say in
I have a pretty simple case which I started solving using foreach(), but then
What is good design in this simple case: Let's say I have a base
What are the rules? OTOH the simple case seems to imply the new type
A very simple use case for creating users in webapp2/appengine can be as follows:
I have a simple test case failing in Django: Model (app/models.py): from django.db import
Let me describe a simple use-case: Running all tests in our project may take

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.