Reputation:
I have some code and I'm having problems trying to change the value of the class 'Player'
My XAML
<Rectangle x:Name="oChar" Fill="Orange" Height="32" Width="32" Canvas.Left="32" Canvas.Top="{Binding Mode=TwoWay}"/>
Code behind:
private Player myPlayer = new Player { left = 32, top = 128 };
public MainPage()
{
this.InitializeComponent();
this.DataContext = myPlayer.top;
myPlayer.top += 32;
}
Class INotiftyProperty
private int _top;
public int top
{
get { return _top; }
set { _top = value; OnPropertyChanged("top"); }
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
First time doing stuff like WPF, any help on why the value wont change or any information would be great!
Upvotes: 0
Views: 55