Jan
17
Written by:
Michael Washington
1/17/2012 12:11 AM
This control has a long history. In brief, this issue started back in September 2011 when LightSwitch team member, Karol Zadora published code that allowed you to display hierarchal data in a nested tree. I covered it in the article: Tree Control: Hierarchical Data with LightSwitch.
The limitation however, is that it does not allow you to associate a tree with another entity. For example, to select a person and see the categories associated with that person. I started to work on this problem myself and asked Sheel Shah for assistance. My attempt was going in the wrong direction, so he just went ahead and created a control that worked.
Then things got busy in the LightSwitch group and he did not get around to releasing the code, until today
Set-Up
Go to: http://code.msdn.microsoft.com/silverlight/Many-to-Many-Control-for-52cd8c6c and download the project.
Unzip the project, navigate to:
\Many to Many Control for Visual Studio LightSwitch\VB\Binaries
and double click on the ManyToManyControls.vsix file to install it.
When you go into Properties of a LightSwitch project, you will now be able to enable the Many To Many Controls extension.
The Tables
We start with the code used in Tree Control: Hierarchical Data with LightSwitch.
We add a Person table to the project.
We then add a ManyToMany table.
We make a relation to the Person table.
We also make a relation to the existing Category table.
The ManyToMany table now resembles the image above.
The Screen
We add a List and Details Screen that includes the People table and the ManyToMany table.
Change the DataGrid that the ManyToMany collection is bound to, to the Many To Many control.
In the properties for the control, set Category as the Navigation Property.
Note: You don’t actually need to set “Category” in the property sheet for the checkbox list. The control should figure it out automatically – you only need to do that if you have more than two relationships off your many-to-many mapping table.
When we run the project, we can select a person and then select the categories we want to associate with them.
Screen Template
See the article: Creating a Visual Studio LightSwitch Screen Template, for an example of a LightSwitch Screen Template that allows easy configuration of this control.
Special Thanks
A special thanks to Sheel Shah and Karol Zadora-Przylecki.
Download Code
The LightSwitch project is available at http://lightswitchhelpwebsite.com/Downloads.aspx
13 comment(s) so far...
To you Michael and Sheel Shah both for the original concept and for the implementation. One of the most usefull extensions at least for me.
By Kostas Christodoulou on
1/18/2012 5:08 AM
|
@Kostas Christodoulou - To be fair Sheel planned to create this control before I spoke to him, my contribution was to annoy him :)
By Michael Washington on
1/18/2012 5:23 AM
|
I desperately need this control for a C# project. Any ideas if we will gate a c# version ?
Martin
By Martin on
2/8/2012 3:27 AM
|
Hi I have installed this extension bu in the property Pannel i cant see the choice List like in the image of the sample.
Matt
By The Mega Matt on
2/28/2012 5:45 PM
|
Hi Michael,
After selecting the many-to-many I get two warnings:
"Warning 1 Assembly 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\Client\Reference\LightSwitchUtilities.Client.dll' references assembly 'Microsoft.LightSwitch.SdkProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', which is ambiguous between 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\ClientGen\Reference\Microsoft.LightSwitch.SDKProxy.dll' (referenced by project 'ClientGenerated') and 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\ManyToManyControls\Client\Reference\Microsoft.LightSwitch.SdkProxy.dll' (referenced by project 'Client'). 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\ClientGen\Reference\Microsoft.LightSwitch.SDKProxy.dll' will be used. If both assemblies are identical, change the references to the same location. C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\Client\Reference\LightSwitchUtilities.Client.dll"
And: "Warning 1 Assembly 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\Client\Reference\LightSwitchUtilities.Client.dll' references assembly 'Microsoft.LightSwitch.SdkProxy, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35', which is ambiguous between 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\ClientGen\Reference\Microsoft.LightSwitch.SDKProxy.dll' (referenced by project 'ClientGenerated') and 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\ManyToManyControls\Client\Reference\Microsoft.LightSwitch.SdkProxy.dll' (referenced by project 'Client'). 'C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\ClientGen\Reference\Microsoft.LightSwitch.SDKProxy.dll' will be used. If both assemblies are identical, change the references to the same location. C:\Users\DaveDell\Documents\ShotCare Apps\ShotTrack\ShotTrack\_Pvt_Extensions\LightSwitchUtilities\Client\Reference\LightSwitchUtilities.Client.dll"
Any Ideas?
Thanks
By fishy on
3/3/2012 11:22 AM
|
I was able to get rid of the warnings by deleting the sdkproxy dll from the references in the clientgenerated.
But, I'm not sure if this will cause other problems.
By fishy on
3/3/2012 4:09 PM
|
how to filter data
Project-->projectItem == projectTOcontract(manytomany) <== Contract
create Contract Screen ,i add Project Data(choice control), and projectTOcontract add query projectitem.id=@PID , then PID bind the choice control(project). run,selected project the manytomany control is no response
By greystar on
3/14/2012 4:07 AM
|
@greystar - Yu want to post any questions on the control to the Microsoft forums http://social.msdn.microsoft.com/Forums/en-US/lsextensibility/threads
By Michael Washington on
3/14/2012 4:08 AM
|
Control is excellent. Reduces programming a lot of code.
One problem: The field shown in the checkbox list is defined as "summary"-field, but it is not really the SUMMARY field of the table (that is defined in "Choices navigation property"). I found out that it is the first string field in the table. But when I place some other field as first string field in the table an error occurs: "Object reference not set to an instance of an object." every time a listbox item is displayed.
By Albert Korstanje on
4/3/2012 1:43 AM
|
@Albert Korstanje - The control was recently updated and that may fix the problem you found, if not, post a message in the Microsoft forums: http://social.msdn.microsoft.com/Forums/en-US/lsextensibility/threads
By Michael Washington on
4/3/2012 4:26 AM
|
Hi
Excellent control. is there anyway to select all the child nodes by clicking the root node? Thanks
By Alfonso on
6/4/2012 8:18 AM
|
@Alfonso - It can be done but you will need to program it.
By Michael Washington on
6/4/2012 8:19 AM
|
Hi, this control is exactly what i need. I have a 2 tier tree but it always opens collapsed. It will be a real pain for users to click on all the level 1 items to get to level 2. How do you get the tree to expand fully on open please?
By Chris Cook on
7/13/2012 5:24 AM
|