samedi 9 mai 2015

Implement PropertyChanged For navigation properties

Well I have some entities with navigation properties some of those entities are used to bind to some DataGrids.

My problem is if I assign a new value to a navigation propertie it doesn't reflect his new values in the UI.

Something like this:

public partial class Movimientos : BaseModel
{
    public Movimientos()
    {
    }
    private Nullable<int> _intIdBodega;
    public Nullable<int> IntIdBodega 
    { 
        get { return _intIdBodega; } 
        set { SetProperty(ref _intIdBodega, value); } 
    } 

    public virtual INV_Bodegas INV_Bodegas { get; set; }
}

public class viewModel
{
    public viewmodel()
    {
        Movimientos mv = new Movimientos();
        mv.INV_Bodegas = db.INV_Bodegas.First();
    }   
} 

That way It doesn't reflect on the UI the changes at mv.INV_Bodegas. But if i reimplemnt the nav propertie as this:

public partial class Movimientos : BaseModel
{
    . . .

    private INV_Bodegas _INV_Bodegas;
    public virtual INV_Bodegas INV_Bodegas
    { 
        get { return _INV_Bodegas; } 
        set { SetProperty(ref _INV_Bodegas, value); } 
    }           
}

The changes reflect at the UI as iexpect (Of course this is the way INPC works).

But My questions are about the perfomance and the boilerplate code:

How can affect the performance of my app ?

Is correct to implement this trough T4 template to avoid handwrite implementation ?

There is another aproach for this task ?

Aucun commentaire:

Enregistrer un commentaire