So I have the following class constructor
public class BolaInfo
{
private double massa;
private double raio;
private double corX;
private double corY;
private double max_x;
private double min_x;
private double max_y;
private double min_y;
private double teste;
private double angulo;
private double velocidade;
private double velX;
private double velY;
private Random rand;
private Random rand1;
public BolaInfo()
{
this.rand = new Random();
this.rand1 = new Random();
MASSA = massa;
VELOCIDADE = velocidade;
RAIO = raio;
CORX = corX;
CORY = corY;
ANGULO = angulo;
ANGULO = (double)(rand.Next(0, 360));
this.ellips = new Ellipse();
ELLIPSE = ellips;
ELLIPSE.SetResourceReference(Ellipse.FillProperty, "BallGrad");
ELLIPSE.Width = RAIO * 2;
ELLIPSE.Height = RAIO * 2;
CORX = rand.Next((int)(RAIO),(int)(650 - RAIO));
CORY = rand1.Next((int)(RAIO), (int)(440 - RAIO));
VELOC_X = velX;
VELOC_X = Math.Cos(angulo * Math.PI / 180);
VELOC_Y = velY;
VELOC_Y = Math.Sin(angulo * Math.PI / 180);
}
public double MASSA { get; set; }
public double RAIO { get; set; }
public double CORX { get; set; }
public double CORY { get; set; }
public double VELOCIDADE { get; set; }
public double VELOC_X { get; set; }
public double VELOC_Y { get; set; }
public double ANGULO { get; set; }
public Ellipse ELLIPSE { get; set; }
}
I’m using a datagrid binded to a list of this class and when I add a new row all looks fine except ELLIPSE.Width, ELLIPSE.Height, CORX, CORY, VELOC_X and VELOC_Y.
The problem is those values are generated by the input in RAIO and acording to the breakpoints it sets its initial value to 0 and doesn’t recalculate those values with the new value of it.
I though of calling functions where the datagrid is declared to set those values correctly but I know it wouldn’t be the best practice way (in my head at least).
How can I fix this without resorting to that way?
Thanks in advance.
it’s hard to tell from your naming conventions, whether you are assigning to attributes or properties.
You also seem to want to use functions or properties. Showing how you bound
RAIOtoBolaInfowould be helpful to. maybe you are looking for the INotifyPropertyChanged-Interface: