none
Binding paths scsm

    Question

  • Hi all,

    Can someone tell me how to figure out what the binding path is for a specific field? I've made a custom preview pane in the bottom of the work items list but for some items i am not able to get the right binding path.

    Someone else also running into this problem?

    Thanks in advance!

    Tuesday, October 11, 2011 9:12 AM

Answers

  • Short answer: Examine your form's Type Projection. Look at the type projection's "type" to know what properties you can bind for that class. Look at the component aliases to bind to related object properties :)

     

    Long answer: Those paths belong to the data context, of course, so you'll want to look at the class or type projection to which the form is targetted. Let's take the Binding Path "AffectedUser.DisplayName" as an example.

    First we need to find the type projection that the form is targetted to, so we'll look at a sample form definition.

    eg: <Form ID="My.Custom.Form" Accessibility="Public" Target="My.Custom.Form.Projection" Assembly="My.Custom.Form.Assembly" TypeName="My.Custom.Form.frmPreview">

    In this example, the type project you want to examine is "My.Custom.Form.Projection" (the Target of the form)

    Let's say the type projection looks something like this:

    <TypeProjection ID="My.Custom.Form.Projection" Accessibility="Public" Type="Change_Request_Library!System.WorkItem.ChangeRequest">
    <Component Path="$Context/Path[Relationship='WorkItem_Library!System.WorkItemAffectedUser']$" Alias="AffectedUser" />
    </TypeProjection>

    If you look at the type projection definition, "AffectedUser" is one of the component aliases. "DisplayName", then, is a property of the System.Domain.User (the related class which the component exposes).

    Basically, your top level bindings (those without "." like "Id" and "Title") will be the properties belonging to the type projections "type" (or seed class)..in my example, System.WorkItem.ChangeRequest.

    You use "<alias>." to traverse the type projection. So, your binding path "AffectedUser.DisplayName" is literally a path from your seed class (System.WorkItem.ChangeRequest) to your Affected User (System.Domain.User)..once you have traveled that path ("AffectedUser."), you bind to a property of that System.Domain.User class ("DisplayName").

    One more caveat; a work item's affected user relationship is many-to-1..meaning a change request can have only 1 affected user. And so, you can just use "AffectedUser.DisplayName" in your binding.

    There are also relationships that are many-to-many..typically, you would bind such relationships to listboxes, or other controls that manage collections. If you try to bind a many-to-many or 1-to-many relationship (otherwise known as a collection) to a single-instance control (such as UserPicker) it won't work.

     

    By the way, Freeman, nice blog post :) I picked up some great tips, thanks! :)



    Tuesday, October 11, 2011 4:16 PM

All replies

  • http://blog.scsmsolutions.com/2011/08/create-custom-user-control-for-scsm-2010/


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com
    Tuesday, October 11, 2011 9:48 AM
    Moderator
  • Hey Anton,

    Thanks for your reply but i don't think this is what i meant. I need to know what i have to type as a Binding path. like these examples:

    Binding Path=AffectedUser.DisplayName (for the name of the affected user)

    Binding Path=AffectedUser.Department

    Binding Path=AffectedUser.Title

    Binding Path=AffectedUser.BusinessPhone

    Binding Path=AssignedTo.DisplayName

    Binding Path=Title

    Binding Path=Id

    I would like to know how i could know/retrieve the parts behind the =

    Tuesday, October 11, 2011 2:09 PM
  • Short answer: Examine your form's Type Projection. Look at the type projection's "type" to know what properties you can bind for that class. Look at the component aliases to bind to related object properties :)

     

    Long answer: Those paths belong to the data context, of course, so you'll want to look at the class or type projection to which the form is targetted. Let's take the Binding Path "AffectedUser.DisplayName" as an example.

    First we need to find the type projection that the form is targetted to, so we'll look at a sample form definition.

    eg: <Form ID="My.Custom.Form" Accessibility="Public" Target="My.Custom.Form.Projection" Assembly="My.Custom.Form.Assembly" TypeName="My.Custom.Form.frmPreview">

    In this example, the type project you want to examine is "My.Custom.Form.Projection" (the Target of the form)

    Let's say the type projection looks something like this:

    <TypeProjection ID="My.Custom.Form.Projection" Accessibility="Public" Type="Change_Request_Library!System.WorkItem.ChangeRequest">
    <Component Path="$Context/Path[Relationship='WorkItem_Library!System.WorkItemAffectedUser']$" Alias="AffectedUser" />
    </TypeProjection>

    If you look at the type projection definition, "AffectedUser" is one of the component aliases. "DisplayName", then, is a property of the System.Domain.User (the related class which the component exposes).

    Basically, your top level bindings (those without "." like "Id" and "Title") will be the properties belonging to the type projections "type" (or seed class)..in my example, System.WorkItem.ChangeRequest.

    You use "<alias>." to traverse the type projection. So, your binding path "AffectedUser.DisplayName" is literally a path from your seed class (System.WorkItem.ChangeRequest) to your Affected User (System.Domain.User)..once you have traveled that path ("AffectedUser."), you bind to a property of that System.Domain.User class ("DisplayName").

    One more caveat; a work item's affected user relationship is many-to-1..meaning a change request can have only 1 affected user. And so, you can just use "AffectedUser.DisplayName" in your binding.

    There are also relationships that are many-to-many..typically, you would bind such relationships to listboxes, or other controls that manage collections. If you try to bind a many-to-many or 1-to-many relationship (otherwise known as a collection) to a single-instance control (such as UserPicker) it won't work.

     

    By the way, Freeman, nice blog post :) I picked up some great tips, thanks! :)



    Tuesday, October 11, 2011 4:16 PM
  • As additional to Aaron.

    Generic property (Id, DisplayName and etc) must be sorrounded by $ sign, for example:

    Binding Path=$Id$

    Binding Path=$DisplayName$


    http://www.scsmsolutions.com/ freemanru (at) gmail (dot) com
    Tuesday, October 11, 2011 7:16 PM
    Moderator
  • oke thanks for this reply.

    I am now going to recreate the actionlog in the previewpane or something like it :p Hopefully i can get it to work!

    Wednesday, October 12, 2011 11:34 AM
  • I want to bind A listView(.NET) to a new relationproperty (I have created with Auth tool a new MP, I have extended Windows ComputerClass with AssignedApplication - a relation to Application Object).

    1. I can't figure out the binding in .NET so I can see all the Applications.

    2. How Can I add a new relationrecord to this AssignedApplication ( so I can add and "add"-button next to the listview)

    Any tips ?

    <ListView Grid.Column="1" Grid.Row="3" Height="53" HorizontalAlignment="Left" Margin="18,12,0,0" Name="listView1" VerticalAlignment="Top" Width="189" DataContext="{Binding Path=AssignedApplication}" />  does not work

     I have added the control to the ComputerForm


    Frank

    Tuesday, October 09, 2012 8:37 AM
  • You should add Binding to ItemsSource.

    As example: http://www.switchonthecode.com/tutorials/wpf-tutorial-using-the-listview-part-1


    SCSMSolutions
    email: freemanru (at) gmail (dot) com

    • Proposed as answer by Aaron Croasmun Tuesday, October 09, 2012 2:04 PM
    Tuesday, October 09, 2012 12:30 PM
    Moderator
  • Thank you for your fast reply. With the example I have solved my first question.

    Any idea how I can pop-up an object selection form to add new objects (applications) to my relation. Do I have to recreate the selection form or can I use a allready existing form from SCSM2012. (like when you add ConfigurationItems to a CI ).

    Any Examples ?


    Frank

    Tuesday, October 09, 2012 12:50 PM
  • Thank you for your fast reply. With the example I have solved my first question.

    Any idea how I can pop-up an object selection form to add new objects (applications) to my relation. Do I have to recreate the selection form or can I use a allready existing form from SCSM2012. (like when you add ConfigurationItems to a CI ).

    Any Examples ?


    Frank

    I 2nd that question! Would really appreciate if anyone could point out how to add the controls for adding CI / WI to a many-to-many relationship.

    A common scenario were this might be needed would be the following:

    You have a Service Offering for Fileshare Modification Requests. Typically the ACLs on fileshares would grant an user either Read / Write / Full access on the share.

    Now I'd like to create a request offering where the requestor is prompted to select users from CMDB for Read access permissions, prompted to select users from CMDB for Write access permissions and prompted to select users from CMDB for Full access permissions. That's currently not possible as we have only 2 mappings available for query results whereas I'd need 3 here.

    I know I can add a custom relationship with a many to many cardinality and then modify the request offering XML to bind the selected users to my custom relationships. But the Service Desk must also be able to create such a request (on behalf of an user who is calling the Service Desk for instance) using the SCSM Console, which means I'd need to create a form where they can select the users for the different permission levels.

    Thanks for enlighten us in advance :)

    Cheers

    Alex

    Tuesday, October 09, 2012 1:38 PM
  • You'll want to use the InstancePickerDialog class. There's an example of it in Travis's custom service request form (this was before service requests were included with Service Manager)

    http://scsmservicerequest.codeplex.com/SourceControl/changeset/view/99885#1113740

    Using IDataItem is still unsupported (as far as I know) so it may change in the future.

    Basic idea: Open the InstancePickerDialog, select your objects, add them to your list control. As long as that list control is correctly bound to a *-many relationship, those selected objects will be related when you submit the form.

    Tuesday, October 09, 2012 1:59 PM
  • Thanks Aaron.

    So I guess I have to stick my head into Authoring in VS with C# and XAML. I was hoping there's some sort of hidden functionality for this in the Authoring Tool, but all I've found was a standard SingleInstancePicker which only works, as the name implies, with many-to-1 cardinality relationships. What a pitty...

    Cheers

    Alex

    Wednesday, October 10, 2012 11:42 AM