Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I'm trying to show an image on a button, however my issue is that the array item (i.e. CurrentPosition) is NULL, rather than the referenced .characterImage.

This means that the XAML doesn't process the TargetNullValue.

          <Binding Path="CurrentPosition[0,2].characterImage"

I could do in C# code, but wanted to see if there is a XAML solution.

Thank you for your help.

What I have tried:

I have tried implementing a
Richard MacCutchan 18-Apr-17 3:04am    
Where does CurrentPosition get set?
Rodimus74 18-Apr-17 19:30pm    
Thanks for your reply Richard.

public sealed partial class MainPage : Page
private aViewModel myViewModel = new aViewModel();

public MainPage()
this.Loaded += OnLoaded;

this.DataContext = myViewModel;


//In the VM

public class aViewModel : INotifyPropertyChanged
public Character[,] CurrentPosition
get { return _currentPosition; }
private set { _currentPosition = value; RaiseProperty("CurrentPosition"); }

public void StartNew()
arrayOfClass[1,1] = new anObject();

CurrentPosition = arrayOfClass[1, 1];

I believe the issue is that the array Object hasn't been created, but the NullTarget isn't protecting the XAML. The XAML would be protected where the array Object existed and the referenced property within the object was null.
Karthik_Mahalingam 19-Apr-17 23:26pm    
Always use  Reply  button, to post Comments/query to the user, so that the user gets notified and responds to your text.
Richard MacCutchan 20-Apr-17 5:07am    
You should update your question with the code so we can see it all in one place. However, I cannot understand what value is in there from the above. The offsets may well be invalid, which you can easily check with your debugger.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900