SCSM 2012: Custom Forms – Simple way to lock controls in Edit mode (Only using XAML)!

A decent part of my work is in customizing Service Manager.

Last year i was contributing author on the Service Manager 2012 Unleashed book, specifically writing chapters about customization (together with Kurt Van Hoecke)

The chapter 23 talks about creating your own forms in Service Manager.

Get the book here: http://www.amazon.com/System-Center-Service-Manager-Unleashed/dp/067233707X/ref=sr_1_1?ie=UTF8&qid=1422965008&sr=8-1&keywords=service+manager

 

In this article I want to show how you in a very easy way can disable controls, based on if it is a new object (creation) or existing object (editing).

I have specifically used this method to lock the field that is the key.

In this case I have a “Name” textbox which is the key of the item, to make sure that a user does not change the name later on.

 

When I make my form, I set the text binding on the textbox to the name property of the data item.

now comes the good stuff:

To be able to enable/disable this textbox, all i have to do is to bind the “IsEnabled” property of the control to the “$New$” property in the dataitem/datacontext.

But since the name of the property contains special characters ($), it is not possible to just write the name.

What you need to do is to add [ ] around the property name in the binding.

Making the complete XAML control look like this:

 

notice the [$IsNew$] which binds the enabled property of the textbox to the $IsNew$ property in the dataitem

 

Any comments is welcome!

Have fun!

And see you next week on NIC! www.nicconf.com

By | 2015-02-03T13:13:36+00:00 February 3rd, 2015|Service Manager (SCSM)|1 Comment

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at http://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

One Comment

  1. Fábio November 11, 2016 at 14:10 - Reply

    Hi Jakob, awesome stuff here. Do you know what other criteria we can use in this context? Like, Status equals X.

Leave A Comment