Select to view content in your preferred language

Positioning the Esri toolkit vertically in Silverlight

722
4
07-07-2010 10:32 PM
AnurithaPathireddy
Emerging Contributor
Hi.... In My silverlight application I kept the EsriToolkit toolbar in a stack Panel.Initially Orientation set for the Stackpanel is Horizontal. I need to Change the Toolbar position to vertical from Horizontal... at runtime...  When MouseLeftButton Dragged down. Changing the Orientation of StackPanel to vertical and Changing the With and Height of the Toolbar in this Event is not Working. what exactly I should do for it?
0 Kudos
4 Replies
DonnieHolmes
Occasional Contributor
We ran into the same issue. We ended up just making our own "Toolbar" out of a stackpanel. You'll probably have to do something similar.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
To get a vertical toolbar, you can edit the template:
[INDENT]Open the project in Blend, rightclick the Toolbar and select to edit a copy of the template.
Select the stackpanel called 'RootElement'.
Change the orientation from Horizontal to Vertical.

[/INDENT]But that doesn't allow to change the orientation at runtime.

One option is to create your own ToolbarExt class derivating from the toolbar and to add an 'Orientation' property:

Example C# code:

 
namespace ToolkitExt
{
public class ToolbarExt : Toolbar
{
public ToolbarExt()
{
this.DefaultStyleKey = typeof(ToolbarExt);
}
�??
public Orientation Orientation
{
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(ToolbarExt), new PropertyMetadata(Orientation.Horizontal));
}
}


XAML code to put in generic.xaml file:

 
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkitext="clr-namespace:ToolkitExt">
<Style TargetType="toolkitext:ToolbarExt">
<Setter Property="ToolbarItemClickEffect" Value="Bounce" />
<Setter Property="MaxItemHeight" Value="110" />
<Setter Property="MaxItemWidth" Value="110" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkitext:ToolbarExt">
<StackPanel x:Name="RootElement" Background="Transparent" HorizontalAlignment="Center" Orientation="{TemplateBinding Orientation}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>


With this class you can initialize the orientation either in XAML or by code at run time.
0 Kudos
MannusEtten
Emerging Contributor
i am going to do the same. build my stackpanel with controls because the time to edit the default template is too much...

I changed the size of pictures in the toolbar and still it is the standard crap from the esri template.
i hate those hidden undocumented standard templates for the layout...
0 Kudos
DominiqueBroux
Esri Frequent Contributor
i am going to do the same. build my stackpanel with controls because the time to edit the default template is too much...

Building your own container is the right way since the Toolbar control is deprecated from 2.3. ESRI doesn't recommend to use it anymore.
0 Kudos