Having a hard time binding my viewmodel class to my view, what am I doing wrong?

I've got a ViewModel class named SpecMapViewModel. I've got it referenced in the Window tag of a window, like this:
xmlns:vm="clr-namespace:SpecMapException.ViewModels"
Next I have it in the Window.Resources section like this:
<vm:SpecMapViewModel x:Key="SpecMapVM" />
And lastly I've trying to bind it to a ComboBox, like this:
<ComboBox x:Name="cmbSources"
DisplayMemberPath="CdValue"
MinWidth="100"
ItemsSource="{Binding ObsSpecimenSources}"
SelectedValue="{Binding CdValue}"
SelectedValuePath="CdValue" />
I've both put a DataContext attribute in the ComboBox's tag, and I've also tried assigning the DataContext in the Window_Loaded event. Neither has worked.
So what am I doing wrong?
Rod

Hi Doctor-Who,
Based on your code snippet, I could not find some issue, I suggest that you could check the DataContext was assigned in a right way. Then I have made a code sample, I assigned the DataContext to window, and the same as your ComboBox. You could refer to it,
and find some different with your code. I hope it would be helpful to solve you question.
<StackPanel>
<ComboBox DisplayMemberPath="CdValue"
MinWidth="100"
ItemsSource="{Binding ObsSpecimenSources}"
SelectedValue="{Binding CdValue}"
SelectedValuePath="CdValue"></ComboBox>
</StackPanel>
SpecMapViewModel.cs
class SpecMapViewModel : INotifyPropertyChanged
private ObservableCollection<SpecMap> _ObsSpecimenSources;
public ObservableCollection<SpecMap> ObsSpecimenSources
get { return _ObsSpecimenSources; }
set
if(value != null)
_ObsSpecimenSources = value;
OnPropertyChanged("ObsSpecimenSources");
public SpecMapViewModel()
ObsSpecimenSources = new ObservableCollection<SpecMap>();
ObsSpecimenSources.Add(new SpecMap {CdValue="abc" });
ObsSpecimenSources.Add(new SpecMap { CdValue = "def" });
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string PropertyName)
PropertyChangedEventHandler handler = PropertyChanged;
if(handler != null)
handler(this,new PropertyChangedEventArgs(PropertyName));
private void Window_Loaded(object sender, RoutedEventArgs e)
SpecMapViewModel viewmodel = new SpecMapViewModel();
this.DataContext = viewmodel;
Best Regards,
Xavier Eoro
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • I am not able to down load the updated version. I have tried several times, the filed is saved many times, but it seems not to update. What am I doing wrong?

    I am trying to update Firefox, but am unable to. I have gone through all of the steps and it seems to not update. I have saved your files several time due to my many tires but the update seems not to go through. What am I doing wrong?

    If there are problems with updating then best is to download the full version and uninstall the currently installed version and delete the Firefox program folder to remove any leftover files.
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 9.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible.
    *Do NOT remove personal data when you uninstall the current version or you lose your bookmarks and other data because all profile folders will be removed.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other profile data are stored elsewhere in the Firefox Profile Folder and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • HT201250 When I open time machine I can click on any time, arrow, or file and nothing happens. What am I doing wrong?

    I cannot get my time machine to work properly.
    When I open the program I see the back-up dates on the right and click the date I would like to access. Nothing happens.
    Next, I try to flip through the dated files but can't get past the first one.
    The arrows do not highlight and therefore I cannot scroll to the date I need to restore an item.
    What am I doing wrong?
    Do I need to reinstall the software?
    Any suggestions are welcomed
    Thank you
    Lonnie Schwartz

    It sounds like you're starting from a Finder window showing something that wasn't backed-up on any of those backups. 
    Try either selecting your Computer or internal HD in the sidebar before going into Time Machine, or pressing Shift+Cmd+C after getting there.
    You might want to take a look at Time Machine - Frequently Asked Question #15A, especially the pink box there.
    If that doesn't help, post back with a bit of detail; are you still on Lion (10.7.x), what sort of Mac do you have, where are your backups (external HD, Time Capsule, Network Drive, etc.)?  It might help to post a screenshot, too.

  • I have an ipod2, that I recently bought. I am having a hard Time with my password, I keep being told the my password is wrong, even after I reset it. I am having problems eith mt iPod touch

    I have an iPod 2 that will only accept my password from time to time this is very frustrating! Any help tou can give me would be greatly appreciated!

    Apple support article:
    FaceTime - Error Processing Registration

  • I'm having trouble taking a landscape with the Camera Fill Feature. What am I doing wrong?

    The application interface rotates to a landscape orientation automatically when using the Camera Fill feature, simply holding the phone itself in a horizontal orientation before entering the Camera Fill mode gives the most predictable results.

    Double check all your audio settings. 
    System Preferences --> Sound --> Input should be set to your audio interface.
    GB --> Preferences --> Audio/MIDI --> Input should be set to your audio interface.
    With your track selected, open the Track Info pane, and select the Edit tab.  Under input make sure that Mono 1 or 2 is selected (which number will depend on which input you plugged your bass cable into).

  • Evaluating TestStand and having a hard time...

    Hi,
    I created a step which calls a module (.dll). This step creates an object and stores its reference into a local variable called "ObjectRef".
    Here's what i did:
     1. insert step->action: "Action"
     2. specify module
     3. filled the assembly text box
     4. selected the right class
     5. filled the .NET invocation text box 
     6. specified the Value text box to : "Locals.ObjectRef" 
    Then, I created another step in order to call the method "getValue" from the object created earlier
    Here's what I did:
     1. insert step->action: "Action2"
     2. specify module
     3. filled the assembly text box
     4. selected the right class
     5. filled the .NET invocation text box with  "Use existing object(ClassLibrary.cls604242_00).getValue()"
     6. Specified the Value text box : "Locals.returnValue"
    At run-time, I would expect to see the value of "returnValue" in the variable panel but I don't. Moreover I'm getting a run-time error message.
    Could anyone indicate me what I'm doing wrong?
    As I mentionned in the subject, I'm conducting an evaluation of this product for my company.
    Thanks
    Mathieu BAzinet
    Solved!
    Go to Solution.
    Attachments:
    action.JPG ‏373 KB
    action2.JPG ‏376 KB
    errorMessage.JPG ‏346 KB

    Yeah my first explanation wasn't very clear, sorry.  You can do the following to correct your second step:
    1) Click anywhere on the text that reads "Use Existing Object(ClassLibrary.cls604242_000)" in the .NET Invocation control.  This will "select" that call and will cause the parameters grid below it to show the parameters for that call.
    2) You will then see one parameter listed in the grid, with a name of "Existing Object".  In the Value column for that row, you should fill in the local variable where your object is stored (Locals.ObjectRef).
    Basically, you had told the step to use an existing object reference, but you never specified what object reference to use.
    Another tip is that if you have an error in one of your calls on your step, it will show the text in red in the .NET Invocation control.  So if you haven't specified a required parameter, it will show that parameter in red in the invocation control.  In this instance there was an error with the single parameter on the Use Existing Object call, and you can see in your screenshot that the parameter is displayed in red text.
    Hope that helps.
    -Jeff

  • I'm having a hard time with my sound blaster z sound card to sync with cs6. Can anyone share with me

    I'm having a hard time with Adobe CS6 synching up with my soundcard. Latency settings and other applications are challenging at this time. I had 3.0, but my Windows 7 computer is now "deceased". Please help.

    I endorse everything that Steve just said but to try and get you going while you're shopping for an audio interface more suitable for sound work than use as a doorstop, try the following:
    Go to the Windows sound control panel and make sure the SB card is selected as the default on both the Recording and Playback tabs.  On the advanced menu for both, set the bit depth and sample rate to either 16/44,100 (CD) or 16/48,000 (Video) depending what suits you best.  Note that your SB card only works natively at 16/48,000  so anything else involves a conversion that the card hides from you.
    Go to the Windows Control panel and, under the sound section, turn off all system sounds (since they can hijack your sound card).  Close every other application that may want to use the sound card (internet for example).
    In Audition, go to Edit/Preferences/Audio Hardware.  Set the device class to MME.  On the drop down menus set the Default Input and Default Output to be your Soundblaster.  On the Master Clock set it for the SB Output (this'll likely be default).  Set the latency at around 200ms (you may need to increase this later if your playback stutters--or you can try decreasing it until you get stutter, then take it back up a bit.  Set the sample rate to whatever you selected on the Windows Sound Control Panel.
    The Soundblaster will likely have installed it's own control menu.  Go to this and select Mic or Line as appropriate for the input and whatever you need for the output.  I can't be more specific as SB keep changing what they call things.
    Hopefully this'll get you going even if it's not the best compromise for quality and latency.

  • I have lost my calendar data and am having a hard time retrieving it from Time Capsule. Can anyone help? I am using Mountain lion OS

    I have lost my iCal data and am having a hard time retrieving it from Time Capsule. I am using Mountain Lion OS om iMac. Can anyone help?

    You cannot see it because it is hidden.. one of those great things apple does.. if it is hidden in your Mac then it will be hidden in the Time Machine Backup.
    You will need to restore the entire folder to a different location.. and unhide it.
    There is some info here about restoring particular files or folders.
    http://pondini.org/TM/16.html
    And some info from Lion which should also relate to Mountain Lion.
    https://discussions.apple.com/thread/3231381?start=0&tstart=0
    There is stuff about recovery near the end.
    One wonders sometimes when Apple make these decisions if they ever think about what happens when something goes wrong. Hiding files..???

  • Having a hard time signing into websites with Safari

    Hi, I'm having a hard time signing in my username and password for e-mail addresses I use and for message boards as well. I use Safari all the time accept for my school website that requires IE. Anyways, I use Comcast and I have been trying to sign into my e-mail address name and everyime I click "sign in mail" Safari says "Safari Can't Open Page". So then, I went to my AIM mail to sign in there and then it said the same thing. Then I went to this Apple Forum to ask if anyone knows what the problem is, and then when I went to sign into here, the same thing. So right now I am using Camino, but can anyone help me with this problem or is anyone having the same problem as me? Thanks.

    I too have been having a problem of logging into certain websites with a username and password. Instead of logging in successfully with Safari, a blank page or an error would occur.
    This happened for: citibank, comcast, sprint, and miscellaneous other sites.
    This problem apparently had something to do with my cookies since erasing my cookies seemed to solve the problem. Here's how to do it:
    Safari -> Preferences...-> Security -> Show Cookies -> Remove All.
    Keywords: login error failure log in log-in unable to trouble
    iBook G4   Mac OS X (10.4.7)   800 Mhz / 640 mb

  • Having a hard time with burning photos onto a CD...

    Whew! I just found the photos I thought I had deleted this morning, they're in my Finder, inside the iPhoto Library. Now I'm having a hard time trying to burn them onto a CD. The size is 232 MB and my MacBook is OSX Lepard. Would you tell me how to do it step by step? I'm not good at this stuff. Thank you in advance for your help.

    It is simple......
    http://www.ehow.com/how_6225993_burn-photos-cd-mac.html

  • I have a macbook pro with 250 GB of Space, 2.2 Processor, 16 GB of Memory 1600MHz, and Intel Iris Pro 1536. I backed up my apps using iTunes but I am having a hard time restoring my apps back to my iPhone 5s so could you please help me?

      I have a macbook pro with 250 GB of Space, 2.2 Processor, 16 GB of Memory 1600MHz, and Intel Iris Pro 1536. I backed up my apps using iTunes but I am having a hard time restoring my apps back to my iPhone 5s so could you please help me?

    So did you ever get your apps back on your iPhone?

  • I am having a hard time with fcpx, it is running so slow.  i upgraded my ram to 12 and have cleaned up my computer to run faster and have changed all my files to proxy files but it is still running SO slow.  please help!

    I am having a hard time with my fcp x running so slow.  i can't even move my mouse without the time wheel coming on and staying up for at least 20 some seconds.  I have upgraded my ram to 12 and changed all my files to proxy files; also i cleaned the crap out of my computer removing all other media files I didn't need and it is still running the same.  Please help!  I have a deadline on my short film to be submitted and I can't finish it like this.  Oh also it ran fine in the beginning but and one day it just started doing this out of no where.  Anything will help!  Thanks

    In addition have you got FileVault switched on as that will kill performance.

  • HT204406 I authorized a second computer on my iTunes account, and downloaded my library from the Cloud to my new computer. However, many songs only partially downloaded, and now I'm having a hard time getting rid of them to do full downloads.

    I authorized a second computer on my iTunes account and tried to get my first computer's library on my second computer via the Cloud. Many of the songs only partially downloaded, and I am having a hard time getting rid of the library with the partial downloads (so I can get full songs). I am considering nuking the current iTunes on the second computer and re-installing, giving myself a clean slate to work with. Is this the right way to go?

    How to use your iPod to move your music to a new computer

  • Hi, I have a power Mac G5 with an airport card and I am having a hard time connecting to my regular NETGEAR router. Any help, Hi, I have a power Mac G5 with an airport card and I am having a hard time connecting to my regular NETGEAR router.PLs help

    Hi, I have a power Mac G5 with an airport card, MAc OS X 10.5.8, Wireless card is Airport Extreme ( 0x14E4,0x4E ) and I am having a hard time connecting to my regular NETGEAR router.  PLS Help,
    Thanks,
    Mishcadola

    I spent 2750 $ for my 24" iMac (price for my region)...
    And the perfect world of Steve Jobs still close, but never we've been in there!

  • I want to take my debit card information off of my itunes account i have a iphone 4 and i m having a hard time with this??

    I want to take my debit card information off of my itunes account i have a iphone 4 im having a hard time?? does anyone know how to put none for the billing information

    http://support.apple.com/kb/ht2534

Maybe you are looking for