Mike B
Mike B

Reputation: 2672

How do I change the default Tab Title for a Visual Studio 2011 RC Lightswitch Detail Screen?

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";
}

Upvotes: 0

Views: 2956

Answers (1)

Mike B
Mike B

Reputation: 2672

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";
    }

Upvotes: 1

Related Questions