I did something similar, but in a behavior so that the ToC was open by default when the viewer launched. You could probably modify it to work in the tool. In the MyBehavior class I used the follwing code (you could probably add this in your dialog code)
#region Behavior Overrides
protected override void OnAttached()
{
base.OnAttached();
UIController.Instance.ShowSidePanel(null, "MapContentsTabItem", false);
}
#endregion
I then added a class called UIController.cs with the following code:
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;
}
}
}
I should add that I used the AddressRouteFinder addin in the code gallery to learn how to do this, and a good deal of this code comes directly from theirs. So kudos goes to them.
Hope this helps!