From another thread I found that if you create a behavior (new project) within your web solution in Visual Studio and create two classes in your behavior addin, MyBehavior.cs and UIController.cs then the Map Contents will load up on the Silverlight Viewer startup. Here's the code:
MyBehavior.cs
-------------------------------------------------------------------------
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Interactivity;
using System.ComponentModel.Composition;
using System.ComponentModel;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Extensibility;
namespace ContentsBehavior.AddIns
{
[Export(typeof(Behavior<Map>))]
[DisplayName("Open Table of Contents by Default")]
[ESRI.ArcGIS.Client.Extensibility.Category("Custom Tool")]
public class MyBehavior : Behavior<Map>
{
#region Behavior Overrides
protected override void OnAttached()
{
base.OnAttached();
System.Windows.Controls.TabControl tab = MapApplication.Current.FindObjectInLayout("SidePanelContainer") as TabControl;
System.Windows.Controls.TabItem tabItem = MapApplication.Current.FindObjectInLayout("MapContentsTabItem") as TabItem;
tab.SelectedItem = tabItem;
tab.Visibility = Visibility.Visible;
tabItem.Visibility = Visibility.Visible;
VisualStateGroup vg = VisualStateManager.GetVisualStateGroups(tab)[0] as VisualStateGroup;
VisualState vs = vg.States[0] as VisualState;
System.Windows.Media.Animation.Storyboard sbShow = vs.Storyboard;
sbShow.Begin();
tab.SelectedItem = tabItem;
}
#endregion
}
}
UiController.cs
---------------------------------------------------------------------------------------------
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Extensibility;
namespace ContentsBehavior.AddIns
{
public sealed class UIController
{
static readonly UIController _instance = new UIController();
public static UIController Instance
{
get { return _instance; }
}
private UIController() { }
public void SetAppBusy(bool busy, string sMessage)
{
System.Windows.Application.Current.RootVisual.Dispatcher.BeginInvoke(
delegate
{
});
}
/// <summary>
/// show Silverlight Viewer's Side Panel
/// </summary>
public bool ShowSidePanel(TabItem tabItem, string sOrItemName, bool bForceVisible)
{
System.Windows.Controls.TabControl tab = MapApplication.Current.FindObjectInLayout("SidePanelContainer") as TabControl;
if (tabItem == null)
{
tabItem = tab.FindName(sOrItemName) as TabItem;
}
if (tabItem != null)
{
tabItem.Visibility = Visibility.Visible;
// Hide if already present
if (tab.Visibility == Visibility.Visible && tabItem.IsSelected && !bForceVisible)
{
VisualStateGroup vg = VisualStateManager.GetVisualStateGroups(tab)[0] as VisualStateGroup;
VisualState vs = vg.States[1] as VisualState;
System.Windows.Media.Animation.Storyboard sbHide = vs.Storyboard;
sbHide.Begin();
}
else if (tab.Visibility == Visibility.Visible)
{
tab.SelectedItem = tabItem;
}
else
{
VisualStateGroup vg = VisualStateManager.GetVisualStateGroups(tab)[0] as VisualStateGroup;
VisualState vs = vg.States[0] as VisualState;
System.Windows.Media.Animation.Storyboard sbShow = vs.Storyboard;
sbShow.Begin();
tab.SelectedItem = tabItem;
}
return true;
}
return false;
}
}
}