0

I have a simple Lightswitch Ap that I am building for use in my business and as a test of Lightswitch. The Ap uses a single table with many fields so I am using a list-Detail screen with the basic info displayed on the selected item along with 3 buttons that open specialty detail screens. The problem I am having is that each detail screen opens in a tab with an identical title of the first field in the table - Table Name (i.e. "HP - Equipment"). all I can find states you should override the DisplayName in the InitializeDataWorkspace() method for that screen but I just see my title briefly flicker as the screen is created only to be overwritten by the default.

Not much code to show...

partial void FinancialDetail_InitializeDataWorkspace(List<IDataService> saveChangesTo)
{
    // Write your code here.
    this.DisplayName = "Financial Detail";
}
Mike B
  • 2,592
  • 3
  • 33
  • 46
  • OK I just discovered that if I use part of the entity data in the label then it works. i.e. this.DisplayName = "Financial Detail" + this.equipment.model; – Mike B Jul 03 '12 at 05:11
  • This is only a partial answer as the label I wanted was fixed text without anything from the entity. – Mike B Jul 03 '12 at 15:12
  • that's funky. are you sure that it's "entity data" instead of just a unique display name. i'd use dotPeek to look for all references of `this.DisplayName`. – Jake Berger Jul 03 '12 at 16:15

1 Answers1

1

I did finally find the correct answer. This has changed in VS11 so searches always got the wrong answer.

Each Screen now has default methods if you view the screen code. The default code is shown as comments. You do have to set the name in all 3 places.

        partial void Equipment_Loaded(bool succeeded)
    {
        //this.SetDisplayNameFromEntity(this.Equipment);
        this.DisplayName = this.Equipment.UnitID + " - Financials";
    }

    partial void Equipment_Changed()
    {
        //this.SetDisplayNameFromEntity(this.Equipment);
        this.DisplayName = this.Equipment.UnitID + " - Financials";
    }

    partial void FinancialDetail_Saved()
    {
        //this.SetDisplayNameFromEntity(this.Equipment);
        this.DisplayName = this.Equipment.UnitID + " - Financials";
    }
Mike B
  • 2,592
  • 3
  • 33
  • 46