0

This post was a repeated post. Found the fix myself. Explanation was bad so did not get proper advice for what I needed.

  • Hi Bucky, thanks for updating your question.There are *a lot* of very similar `NullReferenceException` questions on SO - usually from people not reading into it first of all. The exception isn't referring to the `unitsToUse` field being null (you're trying to assign it, so no problem). It's to do with the `CboMeasure` property being null. Can you post the code that shows where you're setting the DataContext for the View? Also, in C#, the convention is to use `PascalCase`, with `get`ers and `set`ters for Properties - i.e. `public string UnitsToUse { get; set; }`, and make fields `private` – Geoff James Dec 04 '17 at 21:56
  • 1
    As a note, when you use `SelectedValue`, you should also set `SelectedValuePath`. Read the online documentation about these two properties. Also make sure to set the current DataContext (of the ComboBox or one of its parent elements) to an instance of the Device class. – Clemens Dec 04 '17 at 22:00
  • Glad you managed to fix it. You can either post your solution as an answer if you feel it will be useful to others in future; or if it was something specific to your program you could choose to delete the question. Totally up to you :) – Geoff James Dec 05 '17 at 07:13

0 Answers0