Silverlight menu popup direction - silverlight

I have a menu which has nested menu items within them which when hovered over the main menu start point opens the menu structure. However, we have recently moved the menu from the bottom of our Silverlight app to the top of the page and I cannot seem to find the way to change the opening direction when hovering over the starting menu point.
Currently, it opens above the starting menu point and I require the menu to open below it.
<StackPanel x:Name="ToolbarLogo" Grid.Column="0" VerticalAlignment="Top" HorizontalAlignment="Left" Background="{StaticResource ToolbarBackgroundBrush}" Orientation="Horizontal">
<viblend:Menu Visibility="Visible" Canvas.ZIndex="99" Orientation="Horizontal" VerticalAlignment="Bottom" AnimationType="Bounds" x:Name="MenuLogo" Margin="25,0,0,0" Style="{StaticResource ThemeMenuStyle}" HorizontalAlignment="Left" Padding="5,0,5,0">
<viblend:MenuItem Width="129" DropDownWidth="125" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Bottom" Style="{StaticResource ThemeMenuItemStyle}" Padding="10,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Image Source="/ReACTSL;component/Assets/Images/Icons/ReACTLogoPlus.png" Width="100" Height="30"/>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem Tag="ReACTHome" x:Name="mi_ReACTHomeM" Width="125" FontSize="11" Style="{StaticResource ThemeMenuItemStyle}" HorizontalAlignment="Center" Padding="2,5,5,5" ShortcutKey="B" ShortcutModifierKeys="Control" >
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Home" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource HomeIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
<viblend:MenuItem Width="125" FontSize="11" Name="SSRSReportsMenuItem" Style="{StaticResource ThemeMenuItemStyle}" HorizontalAlignment="Center" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="SSRS Reports" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource ReportIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
<viblend:MenuItem Width="125" FontSize="11" Name="CrystalReportsMenuItem" Style="{StaticResource ThemeMenuItemStyle}" HorizontalAlignment="Center" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Crystal Reports" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource ReportIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
</viblend:Menu>
The following style is applied to the menu and and menu items
<Style TargetType="viblend:Menu" x:Key="ThemeMenuStyle">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Padding" Value="3" />
<Setter Property="TabNavigation" Value="Local" />
<Setter Property="Orientation" Value="Horizontal"></Setter>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="HorizontalTemplate">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel x:Name="LayoutRoot" Orientation="Horizontal" VerticalAlignment="Bottom" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="VerticalTemplate">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel x:Name="LayoutRoot" Orientation="Vertical" VerticalAlignment="Top" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="viblend:Menu">
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent" x:Name="Background" Opacity="1">
<ItemsPresenter x:Name="ItemsHost" VerticalAlignment="Top">
</ItemsPresenter>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="viblend:MenuItem" x:Key="ThemeMenuItemStyle">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Padding" Value="9,3,9,3" />
<Setter Property="TabNavigation" Value="Local" />
<Setter Property="RootNormalForeBrush" Value="{StaticResource MenuItemRootForegroundBrush}"/>
<Setter Property="RootHighlightForeBrush" Value="{StaticResource MenuItemRootHighlightForegroundBrush}"/>
<Setter Property="DisabledForeBrush" Value="{StaticResource MenuItemDisabledForegroundBrush}"/>
<Setter Property="NormalForeBrush" Value="{StaticResource MenuItemForegroundBrush}"/>
<Setter Property="HighlightForeBrush" Value="{StaticResource MenuItemHighlightForegroundBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="viblend:MenuItem">
<Grid VerticalAlignment="Top">
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="PopupStates">
<vsm:VisualStateGroup.Transitions>
<vsm:VisualTransition GeneratedDuration="00:00:00.1" To="PopupOpened"/>
<vsm:VisualTransition GeneratedDuration="00:00:00.1" To="PopupClosed"/>
<vsm:VisualTransition GeneratedDuration="00:00:00.1" To="PopupCollapsed"/>
<vsm:VisualTransition GeneratedDuration="00:00:00.2" To="PopupExpanded"/>
</vsm:VisualStateGroup.Transitions>
<vsm:VisualState x:Name="PopupExpanded">
<Storyboard x:Name="ExpandingStoryboard">
<DoubleAnimation
Storyboard.TargetName="AnimationPresenter"
Storyboard.TargetProperty="Percentage"
To="1.0" Duration="0:0:0.2"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="PopupCollapsed">
<Storyboard x:Name="CollapsingStoryboard">
<DoubleAnimation
Storyboard.TargetName="AnimationPresenter"
Storyboard.TargetProperty="Percentage"
To="0.0" Duration="0:0:0.1" />
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="PopupOpened">
<Storyboard x:Name="OpeningStoryboard">
<DoubleAnimation
Storyboard.TargetName="PopupChild"
Storyboard.TargetProperty="Opacity"
To="1.0" Duration="0:0:0.1" />
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="PopupClosed">
<Storyboard x:Name="ClosingStoryboard">
<DoubleAnimation
Storyboard.TargetName="PopupChild"
Storyboard.TargetProperty="Opacity"
To="0.0" Duration="0:0:0.1" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualStateGroup.Transitions>
<vsm:VisualTransition GeneratedDuration="00:00:00.2"/>
</vsm:VisualStateGroup.Transitions>
<vsm:VisualState x:Name="Normal" >
<Storyboard>
<DoubleAnimation Duration="0" Storyboard.TargetName="ImageMargin" Storyboard.TargetProperty="Opacity" To="1"/>
<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0"/>
<DoubleAnimation Duration="0" Storyboard.TargetName="InnerBackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="HeaderMouseOver">
<Storyboard>
<DoubleAnimation Duration="0" Storyboard.TargetName="HeaderBackground" Storyboard.TargetProperty="Opacity" To="1"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="1"/>
<DoubleAnimation Duration="0" Storyboard.TargetName="ImageMargin" Storyboard.TargetProperty="Opacity" To="0"/>
<DoubleAnimation Duration="0" Storyboard.TargetName="InnerBackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="1"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="SelectionStates">
<vsm:VisualStateGroup.Transitions>
<vsm:VisualTransition GeneratedDuration="00:00:00.2"/>
</vsm:VisualStateGroup.Transitions>
<vsm:VisualState x:Name="Unselected">
<Storyboard>
<DoubleAnimation Duration="5" Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To="0"/>
<DoubleAnimation Duration="5" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="0"/>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="Selected">
<Storyboard>
<DoubleAnimation Duration="5" Storyboard.TargetName="Background" Storyboard.TargetProperty="Opacity" To="1"/>
<DoubleAnimation Duration="5" Storyboard.TargetName="BackgroundGradientSelectedDisabled" Storyboard.TargetProperty="Opacity" To="1"/>
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
<vsm:VisualStateGroup x:Name="FocusStates">
<vsm:VisualState x:Name="Focused"/>
<vsm:VisualState x:Name="Unfocused"/>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>
<Rectangle Stroke="{StaticResource MenuImageMarginStrokeBrush}" Fill="{StaticResource MenuImageMarginBrush}" x:Name="ImageMargin" Width="27" StrokeThickness="0" HorizontalAlignment="Left" RadiusX="1" RadiusY="1" Opacity="1"></Rectangle>
<Rectangle Fill="{StaticResource MenuHeaderItemBackgroundBrush}" x:Name="HeaderBackground" RadiusX="1" RadiusY="1" Stroke="{StaticResource MenuHeaderItemStrokeBrush}" Opacity="0"></Rectangle>
<Rectangle Fill="{StaticResource ToolbarHoverBackgroundBrush}" RadiusX="5" RadiusY="5" x:Name="InnerBackgroundGradientOver" Stroke="{StaticResource MenuHighlightStrokeBrush}" Opacity="0"></Rectangle>
<Rectangle Margin="1" Fill="{StaticResource ToolbarHoverBackgroundBrush}" x:Name="BackgroundGradientOver" RadiusX="5" RadiusY="5" Stroke="#FF09638E" Opacity="1"></Rectangle>
<Rectangle x:Name="BackgroundGradientSelectedDisabled" RadiusX="1" RadiusY="1" Opacity="0">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFEFEFEF" Offset="0.046"/>
<GradientStop Color="#FFEFEFEF" Offset="0.194"/>
<GradientStop Color="#FFEFEFEF" Offset="0.507"/>
<GradientStop Color="#FFEFEFEF" Offset="0.521"/>
<GradientStop Color="#FFEFEFEF" Offset="0.811"/>
<GradientStop Color="#FFEFEFEF" Offset="0.982"/>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
<GradientStop Color="#FFEFEFEF"/>
<GradientStop Color="#FFEFEFEF" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
<Rectangle Stroke="{StaticResource MenuSeparatorStroke}" Fill="{StaticResource MenuSeparatorBrush}" x:Name="SeparatorBackground" Margin="1,1,1,1" Height="1" StrokeThickness="0" RadiusX="1" RadiusY="1" Opacity="0"></Rectangle>
<Rectangle Stroke="{StaticResource MenuSelectedStrokeBrush}" Fill="{StaticResource MenuSelectedBrush}" x:Name="Background" StrokeThickness="1" RadiusX="1" RadiusY="1" Opacity="0"></Rectangle>
<!--<Path Visibility="Collapsed" Height="10" HorizontalAlignment="Left" Margin="10,1,0,1.5" x:Name="CheckIcon" Width="10.5" Opacity="0" Fill="{StaticResource MenuCheckIconBrush}" Stretch="Fill" Data="M102.03442,598.79645 L105.22962,597.78918 L106.78825,600.42358 C106.78825,600.42358 108.51028,595.74304 110.21724,593.60419 C112.00967,591.35822 114.89314,591.42316 114.89314,591.42316 C114.89314,591.42316 112.67844,593.42645 111.93174,594.44464 C110.7449,596.06293 107.15683,604.13837 107.15683,604.13837 z"/>-->
<StackPanel Orientation="Horizontal" VerticalAlignment="Top">
<ContentControl
x:Name="contentPresenter"
FontFamily="Segoe UI, Microsoft Sans Serif, Verdana"
Grid.Column="0"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="Top"
Margin="{TemplateBinding Padding}"/>
<Path Margin="10,0,0,0" HorizontalAlignment="Right" x:Name="arrow" Fill="{StaticResource MenuArrowBrush}" VerticalAlignment="Center" RenderTransformOrigin="0,1.2" Stroke="{StaticResource MenuArrowBrush}" StrokeThickness="2" Data="M 1,1.5 L 4.5,5 L 8,1.5" Opacity="1">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</StackPanel>
<Popup x:Name="Popup" VerticalAlignment="Top">
<Border CornerRadius="5,5,5,5" x:Name="PopupChild" BorderThickness="0,0,0,0" Background="Transparent" Opacity="0">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0, 0.5" StartPoint="1,0.5">
<GradientStop Color="#FFB1C7D6" Offset="0"/>
<GradientStop Color="#FFB1C7D6" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Border CornerRadius="5,5,5,5" Height="{TemplateBinding DropDownHeight}" x:Name="PopupChild2" BorderThickness="1" BorderBrush="{StaticResource MainMenuBackgroundBrush}" Background="{StaticResource MainMenuBackgroundBrush}" Opacity="1">
<utilityControls:ScrollablePanel utilityControls:ScrollablePanel.VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}" x:Name="ScrollablePanel" HorizontalScrollBarVisibility="Disabled">
<ItemsPresenter Margin="1" x:Name="ItemsHost" VerticalAlignment="Top">
</ItemsPresenter>
</utilityControls:ScrollablePanel>
</Border>
</Border>
</Popup>
<!--<utilities:ExpandableContentControl x:Name="AnimationPresenter" VerticalAlignment="Top">
</utilities:ExpandableContentControl>-->
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

This is only a guess: Try set the VerticalAlignment of the menu root element to Top. It seems to me the menu is too big for the Stackpanel and will therefore be rendered beyond the bottom resp. top of the StackPanel (by design).
<viblend:Menu VerticalAlignment="Top" ...>
...
</viblend:Menu>

Just for information with anybody else who may be struggling with a similar problem with the VIBlend menu.
<Grid x:Name="LayoutRoot" Margin="0">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition x:Name="ToolbarContainer" Height="Auto"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<viblend:Menu x:Name="MenuLogo" Orientation="Horizontal" AnimationType="Bounds" Style="{StaticResource ThemeMenuStyle}" Height="40" Margin="25,0,0,0" HorizontalAlignment="Left" Padding="5,0,5,0" VerticalAlignment="Top">
<viblend:MenuItem Width="129" DropDownWidth="125" FontSize="11" Style="{StaticResource ThemeMenuItemStyle}" Padding="10,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Image Source="/ReACTSL;component/Assets/Images/Icons/ReACTLogoPlus.png" Width="100" Height="30"/>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem Tag="ReACTHome" x:Name="mi_ReACTHomeM" Width="125" FontSize="11" Style="{StaticResource ThemeMenuItemStyle}" Padding="2,5,5,5" ShortcutKey="B" ShortcutModifierKeys="Control" >
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Home" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource HomeIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
<viblend:MenuItem Width="125" FontSize="11" Name="SSRSReportsMenuItem" Style="{StaticResource ThemeMenuItemStyle}" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="SSRS Reports" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource ReportIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
<viblend:MenuItem Width="125" FontSize="11" Name="CrystalReportsMenuItem" Style="{StaticResource ThemeMenuItemStyle}" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Crystal Reports" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource ReportIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
<viblend:MenuItem Tag="Configuration" Width="125" FontSize="11" Style="{StaticResource ThemeMenuItemStyle}" DropDownWidth="120" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Configuration" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource ConfigIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem Style="{StaticResource ThemeMenuItemStyle}" Width="125" FontSize="11" DropDownWidth="220" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Case" Foreground="White" VerticalAlignment="Center"></TextBlock>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem x:Name="mi_Assessments" Text="Assessments" Tag="ListAssessment" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ActionStages" Text="Case Action Stages" Tag="ListActionStage" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_AgenciesContacts" Text="Case Agencies & Contacts" Tag="ListAgency" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_Companies" Text="Case Companies" Tag="ListCompany" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CostingTypes" Text="Case Costing Types" Tag="ListCostingType" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseCostingTypeCategories" Text="Case Costing Type Categories" Tag="ListCostingTypeCategories" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseDefinitions" Text="Case Definitions" Tag="ListCaseDefinitions" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseOutcomes" Text="Case Outcomes" Tag="ListCaseOutcome" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseStagePriorities" Text="Priority Levels" Tag="ListPriorityLevels" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseSources" Text="Case Sources" Tag="ListCaseSource" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseStatusValues" Text="Case Status Values" Tag="ListCaseTypeStatusValue" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseTypes" Text="Case Types" Tag="ListCaseType" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseWards" Text="Case Wards" Tag="ListCaseWards" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_NotActionedReasons" Text="Not Actioned Reasons" Tag="ListNoActionReason" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_OrderCategory" Text="Order Type Categories" Tag="ListOrderCategories" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CaseRechargeTypes" Text="Recharge Types" Tag="ListCaseReChargeTypes" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_SupportTypes" Text="Support Types" Tag="ListSupportType" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
</viblend:MenuItem>
<viblend:MenuItem Style="{StaticResource ThemeMenuItemStyle}" Width="125" FontSize="11" HorizontalAlignment="Center" DropDownWidth="200" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Individual" Foreground="White" VerticalAlignment="Center"></TextBlock>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem x:Name="mi_AgeRange" Text="Age Ranges" Tag="ListAgeRange" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_EthnicOrigin" Text="Ethnic Origins" Tag="ListEthnicOrigin" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_Landlords" Text="Landlords" Tag="ListLandLord" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_Religions" Text="Religions" Tag="ListReligion" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_SexOrientation" Text="Sexual Orientations" Tag="ListSexualOrientation" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_TenancyTypes" Text="Tenancy Types" Tag="ListTenancyType" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_TenureTypes" Text="Tenure Types" Tag="ListTenureType" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_IndTitles" Text="Titles" Tag="ListIndividualTitles" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
</viblend:MenuItem>
<viblend:MenuItem Style="{StaticResource ThemeMenuItemStyle}" Width="125" FontSize="11" HorizontalAlignment="Center" VerticalAlignment="Bottom" DropDownWidth="200" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Settings" Foreground="White" VerticalAlignment="Center"></TextBlock>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem x:Name="mi_ChangeUserPassword" Text="Change Password" Tag="/ChangeUserPassword/True" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CorrTemplates" Text="Document Templates" Tag="ListCorrespondenceTemplates" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_OutOfOffice" Text="Out Of Office" Tag="/OutOfOffice/0" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ReAllocateStaffOfficers" Text="Reallocate Staff Officers" Tag="ReAllocateStaffOfficers" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_StaffOfficers" Text="Staff Officers" Tag="/ListStaffOfficer/0" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
</viblend:MenuItem>
</viblend:MenuItem>
<viblend:MenuItem Width="125" x:Name="mi_Administration" FontSize="11" HorizontalAlignment="Center" DropDownWidth="200" Style="{StaticResource ThemeMenuItemStyle}" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Administration" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource AdminIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
<viblend:MenuItem x:Name="mi_AuditTrail" Text="Audit Trail" Tag="AuditTrail" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CloudAdmin" Text="Cloud Administration" Tag="CloudAdmin" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_CustomFields" Text="Custom Fields" Tag="CustomFields" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ConfigurableFields" Text="Configurable Fields" Tag="ConfigurableFields" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ExchangeAdmin" Text="Email / Exchange Settings" Tag="ExchangeAdmin" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_FindSettings" Text="Find Settings" Tag="FindSettings" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_Holidays" Text="Holidays" Tag="ListHolidays" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_Imports" Text="Import(s)" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5">
<viblend:MenuItem x:Name="mi_PendingNoteImports" Text="Pending Notes" Tag="PendingNoteImport" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_DamageReportImports" Text="Damage Reports" Tag="DamageReportImport" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_OperatorReportImports" Text="Operator Reports" Tag="OperatorReportImport" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_YouthReportImports" Text="Youth Reports" Tag="YouthReportImport" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
</viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ManageLoginsAndCaseLocks" Text="Manage Logins / Case Locks" Tag="ManageLoginsAndLocks" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_MandatoryFields" Text="Mandatory Fields" Tag="MandatoryFields" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_MappingExport" Text="Mapping Export Format" Tag="MappingExportFormat" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_PostCodeSearch" Text="Post Code Search" Tag="ListPostCodeSearch" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ReACTSettings" Text="ReACT Today Settings" Tag="ReACTTodaySettings" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_ReportConfig" Text="Report Access Configuration" Tag="ReportAccessConfigration" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_SatisfactionForms" Text="Satisfaction Form" Tag="ListFeedbackCategory" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_SysSettings" Text="System Administration" Tag="SystemAdmin" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_UserAccounts" Text="User Account" Tag="/UserAccount/0" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
<viblend:MenuItem x:Name="mi_UserGroups" Text="User Groups" Tag="UserGroups" Style="{StaticResource ThemeMenuItemStyle}" ImageSource="/ReACTSL;component/Assets/Images/Icons/circle1.png" Padding="5"></viblend:MenuItem>
</viblend:MenuItem>
<viblend:MenuItem Width="125" FontSize="11" Tag="LogOut" HorizontalAlignment="Center" DropDownWidth="110" Style="{StaticResource ThemeMenuItemStyle}" Padding="2,5,5,5">
<viblend:MenuItem.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Logout" Foreground="White" VerticalAlignment="Center"></TextBlock>
<Image Source="{StaticResource LogOutIcon}" HorizontalAlignment="Left" Grid.Column="0" Width="25" Height="25" Margin="1"></Image>
</Grid>
</DataTemplate>
</viblend:MenuItem.HeaderTemplate>
</viblend:MenuItem>
</viblend:MenuItem>
</viblend:Menu>
<StackPanel x:Name="ToolbarAccessibility" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Center" Orientation="Horizontal">
...
</StackPanel>
<viblend:Menu x:Name="MenuIcons" Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Top" AnimationType="Bounds" Margin="0,0,25,0" Style="{StaticResource ThemeMenuStyle}" HorizontalAlignment="Right" Padding="5,0,5,0">
...
</viblend:Menu>
<ScrollViewer x:Name="scrollViewer" Margin="0" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" VerticalAlignment="Stretch" Background="{StaticResource PageBackgroundBrush}" BorderThickness="0">
<navigation:Frame HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="ContentFrame" Navigating="ContentFrame_Navigating">
<navigation:Frame.UriMapper>
<urimapper:UriMapper>
<urimapper:UriMapping Uri="Login" MappedUri="/Login.xaml" />
</urimapper:UriMapper>
</navigation:Frame.UriMapper>
</navigation:Frame>
</ScrollViewer>
</Grid>
</Grid>
The problem was with the layout of the menus container. Having re-written the page which contains the menu along with the applications content, with help of the sample code from VIBlend, it works as expected.

Related

Create a digital clock using only xaml code in wpf

I wonder if it is possible to create a digital clock in xaml using animation (without background code tags)
The analog clock can be realized by converting the current time to the angle by matrix conversion, but the digital clock can't be operated like this. I tried a lot of methods, but it didn't work. Does anyone know if there is any good way to implement it?
Analog clock implementation
<Window>
<Window.Resources>
<FrameworkElement x:Key="time" Tag={x:Static s:DateTime.Now}/>
<TransformGroup x:Key="transformHour">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Hour}"
Y="{Binding Source={StaticResource time},Path=Tag.Minute}"/>
<MatrixTransform Matrix="30 0 0.5 0 0 0"/>
</TransformGroup>
<TransformGroup x:Key="transformMinute">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Minute}"
Y="{Binding Source={StaticResource time},Path=Tag.Second}"/>
<MatrixTransform Matrix="6 0 0.1 0 0 0"/>
</TransformGroup>
<TransformGroup x:Key="transformSecond">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Second}"/>
<MatrixTransform Matrix="6 0 0 0 0 0"/>
</TransformGroup>
<Style TargetType="{x:Type Path}">
<Setter Property="Stroke"
Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="StrokeThickness" Value="3"/>
<Setter Property="StrokeDashCap" Value="Triangle"/>
</Style>
</Window.Resources>
<Viewbox>
<Canvas Width="200" Height="200">
<Canvas.RenderTransform>
<TranslateTransform X="100" Y="100"/>
</Canvas.RenderTransform>
<Path Data="M 0 -90 A 90 90 0 1 1 -0.01 -90"
StrokeDashArray="0 3.14157" />
<Path Data="M 0 -90 A 90 90 0 1 1 -0.01 -90"
StrokeDashArray="0 7.854"
StrokeThickness="6"/>
<Border Background="LightBlue" Width="10" Height="80" RenderTransformOrigin="0.5 0">
<Border.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="bor_Second" Angle="{Binding Source={StaticResource transformSecond},Path=Value.OffsetX}"/>
<RotateTransform Angle="180"/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Border Background="LightGreen" Width="10" Height="60" RenderTransformOrigin="0.5 0">
<Border.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="bor_Minute" Angle="{Binding Source={StaticResource transformMinute},Path=Value.OffsetX}"/>
<RotateTransform Angle="180"/>
</TransformGroup>
</Border.RenderTransform>
</Border>
<Border Background="LightGray" Width="10" Height="40" RenderTransformOrigin="0.5 0">
<Border.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="bor_Hour" Angle="{Binding Source={StaticResource transformHour},Path=Value.OffsetX}"/>
<RotateTransform Angle="180"/>
</TransformGroup>
</Border.RenderTransform>
</Border>
</Canvas>
</Viewbox>
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="bor_Hour"
Storyboard.TargetProperty="Angle"
IsAdditive="True"
Duration="12:0:0"
From="0" To="360"
RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="bor_Minute"
Storyboard.TargetProperty="Angle"
IsAdditive="True"
Duration="1:0:0"
From="0" To="360"
RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="bor_Second"
Storyboard.TargetProperty="Angle"
IsAdditive="True"
Duration="0:1:0"
From="0" To="360"
RepeatBehavior="Forever"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
</Window>
Digital clock (there is an error), I feel that it is more troublesome to use this idea. Does anyone know if there is any good way to implement it?
<Window>
<Window.Resources>
<!--current time-->
<FrameworkElement x:Key="time" Tag="{x:Static s:DateTime.Now}"/>
<!--Current minutes remaining seconds-->
<TransformGroup x:Key="transformSecond">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Second}" Y="60"/>
<MatrixTransform Matrix="-1 0 1 0 0 0"/>
</TransformGroup>
<!--Remaining seconds interval-->
<FrameworkElement x:Key="timeSpanSecond"
Tag="{Binding Source={StaticResource transformSecond},Path=Value.OffsetX,StringFormat={}{0:F0}}"/>
<!--Current hours remaining minutes-->
<TransformGroup x:Key="transformMinute">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Minute}" Y="60"/>
<MatrixTransform Matrix="-1 1 1 0 0 1"/>
</TransformGroup>
<!--Remaining minute interval-->
<FrameworkElement x:Key="timeSpanMinute"
Tag="{Binding Source={StaticResource transformMinute},Path=Value.OffsetX,StringFormat={}{0:F0}}"/>
<!--Next minute-->
<FrameworkElement x:Key="minuteNext"
Tag="{Binding Source={StaticResource transformMinute},Path=Value.OffsetY}"/>
<!--Hours remaining on the day-->
<TransformGroup x:Key="transformHour">
<TranslateTransform X="{Binding Source={StaticResource time},Path=Tag.Hour}" Y="24"/>
<MatrixTransform Matrix="-1 1 1 0 0 1"/>
</TransformGroup>
<!--Remaining hours interval-->
<FrameworkElement x:Key="timeSpanHour"
Tag="{Binding Source={StaticResource transformHour},Path=Value.OffsetX,StringFormat={}{0:F0}}"/>
<!--Next hour-->
<FrameworkElement x:Key="hourNext"
Tag="{Binding Source={StaticResource transformHour},Path=Value.OffsetY}"/>
</Window.Resources>
<Grid>
<!--Width:Current seconds-->
<!--Text:Current remaining seconds(TimeSpan)-->
<TextBlock x:Name="tbk_Second" Visibility="Hidden"
Width="{Binding Source={StaticResource time},Path=Tag.Second}"
Text="{Binding Source={StaticResource timeSpanSecond},StringFormat=0:0:{0},Path=Tag}"/>
<TextBlock x:Name="tbk_Minute" Visibility="Hidden"
Width="{Binding Source={StaticResource time},Path=Tag.Minute}"
Text="{Binding Source={StaticResource timeSpanMinute},StringFormat=0:{0}:0,Path=Tag}">
</TextBlock>
<TextBlock x:Name="tbk_Hour" Visibility="Hidden"
Width="{Binding Source={StaticResource time},Path=Tag.Hour}"
Text="{Binding Source={StaticResource timeSpanHour},StringFormat={}{0}:0:0,Path=Tag}"/>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">
<Run Text="{Binding ElementName=tbk_Hour,Path=Width,StringFormat={}{0:F0}}"/>
<Run Text=":"/>
<Run Text="{Binding ElementName=tbk_Minute,Path=Width,StringFormat={}{0:F0}}"/>
<Run Text=":"/>
<Run Text="{Binding ElementName=tbk_Second,Path=Width,StringFormat={}{0:F0}}"/>
</TextBlock>
</Grid>
<Window.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard >
<DoubleAnimation Storyboard.TargetName="tbk_Hour"
Storyboard.TargetProperty="Width"
BeginTime="{Binding ElementName=tbk_Minute,Path=Text}"
Duration="{Binding ElementName=tbk_Hour,Path=Text}"
From="{Binding Source={StaticResource hourNext},Path=Tag}"
To="23"/>
<DoubleAnimation Storyboard.TargetName="tbk_Hour"
Storyboard.TargetProperty="Width"
BeginTime="{Binding ElementName=tbk_Hour,Path=Text}"
Duration="24:0:0"
From="0"
To="23"
RepeatBehavior="Forever"/>
<DoubleAnimation Storyboard.TargetName="tbk_Minute"
Storyboard.TargetProperty="Width"
BeginTime="{Binding ElementName=tbk_Second,Path=Text}"
Duration="{Binding ElementName=tbk_Minute,Path=Text}"
From="{Binding Source={StaticResource minuteNext},Path=Tag}"
To="59"/>
<DoubleAnimation Storyboard.TargetName="tbk_Minute"
Storyboard.TargetProperty="Width"
BeginTime="{Binding ElementName=tbk_Minute,Path=Text}"
Duration="1:0:0"
From="0"
To="59"
RepeatBehavior="Forever"/>
<DoubleAnimation
Storyboard.TargetName="tbk_Second"
Storyboard.TargetProperty="Width"
Duration="{Binding ElementName=tbk_Second,Path=Text}"
From="{Binding Source={StaticResource time},Path=Tag.Second}"
To="59"
/>
<DoubleAnimation Storyboard.TargetName="tbk_Second"
Storyboard.TargetProperty="Width"
BeginTime="{Binding ElementName=tbk_Second,Path=Text}"
Duration="0:1:0"
From="0"
To="59"
RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
</Window>
Maybe this is the answer you want :)
<Window x:Class="WpfApp6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d"
Title="MainWindow"
Height="450"
Width="800">
<Grid>
<Grid.Resources>
<!--Set x: share to get the latest every time-->
<system:DateTime x:Key="DateTime"
x:Shared="False" />
<Storyboard x:Key="Storyboard">
<!--Use keyframe animation to update datetime -->
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="DataContext"
Duration="0:0:1"
RepeatBehavior="Forever"
AutoReverse="False">
<DiscreteObjectKeyFrame KeyTime="50%"
Value="{StaticResource DateTime}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<!--Get datetime from DataContext-->
<TextBlock Text="{Binding RelativeSource={RelativeSource Self},Path=DataContext.Now}"
DataContext="{StaticResource DateTime}">
<TextBlock.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard}" />
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
</Grid>
</Window>
I recommend you do it based on textblocks and a suitable font like this one:
https://www.keshikan.net/fonts-e.html
Your textblocks are bound to propertys that could be set by an async function calling 'DateTime.Now();'
here is a XAML-Example:
<Border HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,40" Background="DarkGray" BorderThickness="1,1,0,0" BorderBrush="Gray">
<Grid>
<!-- Displays the actual time in red-->
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Opacity="0.6" Foreground="Red" FontSize="20" Text="{Binding Hour, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Opacity="0.6" Foreground="Red" FontSize="20" FontFamily="DSEG7 Classic Mini" >:</TextBlock>
<TextBlock Opacity="0.6" Foreground="Red" FontSize="20" Text="{Binding Min, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Opacity="0.6" Foreground="Red" FontSize="20" FontFamily="DSEG7 Classic Mini">:</TextBlock>
<TextBlock Opacity="0.6" Foreground="Red" FontSize="20" Text="{Binding Sec, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
</StackPanel>
<!-- Creates a Glow Effect -->
<StackPanel Orientation="Horizontal" Margin="2">
<StackPanel.Effect>
<BlurEffect KernelType="Gaussian" Radius="3"/>
</StackPanel.Effect>
<TextBlock Foreground="Red" FontSize="20" Text="{Binding Hour, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Foreground="Red" FontSize="20" FontFamily="DSEG7 Classic Mini" >:</TextBlock>
<TextBlock Foreground="Red" FontSize="20" Text="{Binding Min, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Foreground="Red" FontSize="20" FontFamily="DSEG7 Classic Mini">:</TextBlock>
<TextBlock Foreground="Red" FontSize="20" Text="{Binding Sec, FallbackValue=00, StringFormat=00}" FontFamily="DSEG7 Classic Mini" ></TextBlock>
</StackPanel>
<!-- Creates the effect of turned of segments -->
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Opacity="0.1" FontSize="20" Text="88" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Opacity="0.1" FontSize="20" FontFamily="DSEG7 Classic Mini" >:</TextBlock>
<TextBlock Opacity="0.1" FontSize="20" Text="88" FontFamily="DSEG7 Classic Mini" ></TextBlock>
<TextBlock Opacity="0.1" FontSize="20" FontFamily="DSEG7 Classic Mini">:</TextBlock>
<TextBlock Opacity="0.1" FontSize="20" Text="88" FontFamily="DSEG7 Classic Mini" ></TextBlock>
</StackPanel>
</Grid>
</Border>
it would be even easier using only one textblock and a string format but this example I already had lying around :)

How can I add watermark text to a textbox in wpf?

Im working on a wpf application.How I can add watermark text to the textbox and passwordbox?
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Platforma Smart School 1.0" Height="580" Width="880"
Icon="/WpfApplication4;component/Images/capturennnnnn12_256px%20%282%291.ico">
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/WpfApplication1;component/Images/
hp-colorful-books-hd-105609.jpg" />
</Grid.Background>
<Rectangle Height="334" HorizontalAlignment="Left" Margin="608,162,0,0"
Name="rectangle1" Stroke="#FFDBD8D8" VerticalAlignment="Top" Width="222"
Fill="#FFF0F0F0" />
<Button Height="34" HorizontalAlignment="Left" Margin="630,434,0,0"
Name="button1" VerticalAlignment="Top" Width="178" FontSize="13"
Foreground="#FF555555" />
<TextBox Height="34" HorizontalAlignment="Left" Margin="630,219,0,0"
Name="textBox1" VerticalAlignment="Top" Width="178" FontSize="14" Text=""
Foreground="#FF7C7A7A" />
<PasswordBox Height="32" HorizontalAlignment="Left" Margin="630,304,0,0"
Name="passwordBox1" VerticalAlignment="Top" Width="178" FontSize="14"
FontFamily="Segoe UI"/>
<Image Height="134" HorizontalAlignment="Left" Margin="606,12,0,0"
Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="224"
Source="/WpfApplication1;component/Images/Capture3.PNG" />
<Label Content=" Smart School" Height="31" HorizontalAlignment="Left"
Margin="251,498,0,0" Name="label1" VerticalAlignment="Top" Width="227" />
</Grid>
Take a look at this SO Question. The second answer of creating an Attached Property is what I would suggest.
There are also some extended WPF controls that can help: http://wpftoolkit.codeplex.com/wikipage?title=WatermarkTextBox
Edit: Added Extended WPF Toolkit link.
Or you could try this code
<Grid>
<Grid.Resources>
<VisualBrush x:Key="LoginHint" Stretch="None" AlignmentX="Left" AlignmentY="Top" >
<VisualBrush.Transform>
<TranslateTransform X="5" Y="7" />
</VisualBrush.Transform>
<VisualBrush.Visual>
<Grid HorizontalAlignment="Left">
<TextBlock FontFamily="SEGOEWP" FontSize="10" FontWeight="Normal"
HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="Gray" FontStyle="Italic" Opacity="1" Text="Enter Username"/>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label x:Name="lblUserName" Content="User Name" Grid.Column="0" VerticalAlignment="Top" Margin="5"/>
<TextBox x:Name="waterMarkTextBox" Width="100" Height="25" Grid.Column="1"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="5">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="Transparent"/>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=waterMarkTextBox,Path=Text}" Value="" >
<Setter Property="Background" Value="{StaticResource LoginHint}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
</Grid>
MahApps.Metro has a built-in watermark control and it's fairly straightforward to use. It does work with a PasswordBox.
<AdornerDecorator>
<PasswordBox Name="password"
Width="200"
HorizontalAlignment="Right">
<Controls:TextBoxHelper.Watermark>Password</Controls:TextBoxHelper.Watermark>
</PasswordBox>
</AdornerDecorator>

How to move a Image using XAML?

I want to move a Image control in WPF (Actually, the Image will move from left to right then to left then to right, looply repeat this.), I want to use XAML to control it. Also, I want the image control to move when hiting MouseEnter event.
Below is my Image in a Grid:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="TimeZoneDaemonApp.Window1"
Title="TimeZone Browser (CodeBy:CS48516)" Icon="/TimeZoneDaemonApp;component/Images/Settings.png" Background="{x:Null}" WindowStartupLocation="Manual" Width="704" Height="170" Opacity="1" WindowStyle="None" AllowsTransparency="True">
<Grid PreviewMouseLeftButtonDown="Grid_PreviewMouseLeftButtonDown" PreviewMouseRightButtonDown="Grid_PreviewMouseRightButtonDown" >
<Grid.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
</Style>
</Grid.Resources>
<Border OpacityMask="White" Height="100" >
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset=".6"/>
<GradientStop Color="Green" Offset=".9"/>
</LinearGradientBrush>
</Border.Background>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border Grid.Column="0"><TextBlock FontFamily="#微软雅黑" Padding="0,5,0,0" FontSize="12pt" Foreground="Black" FontWeight="bold" Background="#FFF87800" TextAlignment="Center"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="1"><TextBlock Background="#FFB0D428" Padding="0,5,0,0" FontFamily="#微软雅黑" FontSize="16" FontWeight="Bold" Foreground="Black" Text="New York" TextAlignment="Center"/></Border>
<Border Grid.Column="2"><TextBlock Background="#FF2283E4" Padding="0,5,0,0" FontFamily="#微软雅黑" FontSize="16" FontWeight="Bold" Foreground="Black" Text="London" TextAlignment="Center"/></Border>
<Border Grid.Column="3"><TextBlock Background="#FF20D4D0" Padding="0,5,0,0" FontFamily="#微软雅黑" FontSize="16" FontWeight="Bold" Foreground="Black" Text="Pairs" TextAlignment="Center"/></Border>
<Border Grid.Column="4"><TextBlock Background="#FF28D428" Padding="0,5,0,0" FontFamily="#微软雅黑" FontSize="16" FontWeight="Bold" Foreground="Black" Text="Sydney" TextAlignment="Center"/></Border>
<Border Grid.Column="5"><TextBlock Background="#FFD040F8" Padding="0,5,0,0" FontFamily="#微软雅黑" FontSize="16" FontWeight="Bold" Foreground="Black" Text="Brasilia" TextAlignment="Center"/></Border>
<Border Grid.Column="0" Grid.Row="1"><TextBlock x:Name="HK" Padding="0,5,0,0" Background="#FFA04C00" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="1" Grid.Row="1"><TextBlock x:Name="NY" Padding="0,5,0,0" Background="#FF708418" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="2" Grid.Row="1"><TextBlock x:Name="UK" Padding="0,5,0,0" Background="#FF184880" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="3" Grid.Row="1"><TextBlock x:Name="PS" Padding="0,5,0,0" Background="#FF188480" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="4" Grid.Row="1"><TextBlock x:Name="SD" Padding="0,5,0,0" Background="#FF188418" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="5" Grid.Row="1"><TextBlock x:Name="BR" Padding="0,5,0,0" Background="#FF7800A8" FontFamily="#微软雅黑" FontSize="12" Foreground="White" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="None"><Run Text="Hong Kong"/></TextBlock></Border>
<Border Grid.Column="0" Grid.Row="2"><TextBlock x:Name="HKT" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" FontWeight="Bold"><Run Text="Load"/></TextBlock></Border>
<Border Grid.Column="1" Grid.Row="2"><TextBlock x:Name="NYT" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" FontWeight="Bold"><Run Text="Load"/></TextBlock></Border>
<Border Grid.Column="2" Grid.Row="2"><TextBlock x:Name="UKT" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" FontWeight="Bold"><Run Text="Load"/></TextBlock></Border>
<Border Grid.Column="3" Grid.Row="2"><TextBlock x:Name="PST" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" FontWeight="Bold"><Run Text="Load"/></TextBlock></Border>
<Border Grid.Column="4" Grid.Row="2"><TextBlock x:Name="SDT" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" FontWeight="Bold"><Run Text="Load"/></TextBlock></Border>
<Border Grid.Column="5" Grid.Row="2"><TextBlock x:Name="BRT" Padding="0,5,0,0" FontFamily="#Gill Sans MT" FontSize="21pt" Foreground="White" TextAlignment="Center" TextDecorations="None" FontWeight="Bold" Background="Transparent"><Run Text="Load"/></TextBlock></Border>
</Grid>
</Border>
<Image HorizontalAlignment="Left" Height="50" Margin="0,0,0,0" Source="Images/cloud.png" Stretch="Fill" VerticalAlignment="Top" Width="190">
</Image>
</Grid>
I am a new learner for WPF, AnyOne can Help on this? thx.
Actually I have found a chapter in SOF: WPF. Easiest way to move Image to (X,Y) programmatically?
Well, that's not what I want.
My Answer listed below:
we need a Canvas to contain the images and we can use the "Left" property of the Canvas to move the Image.
<Canvas x:Name="MyCanvas">
<Canvas.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard >
<Storyboard Storyboard.TargetName="img1" Storyboard.TargetProperty="(Canvas.Left)">
<DoubleAnimation From="0" To="514" Duration="0:0:20" AccelerationRatio=".2" DecelerationRatio=".8" RepeatBehavior="23:59:59" AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Canvas.Triggers>

Styling a GroupBox

I'm trying to create a GroupBox design like this.
I have looked at the GroupBox.HeaderTemplate
but I'm having problems creating the blue background color, with a width of 100%.
The same goes for the border.
My code so far
<GroupBox.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Content="{Binding}" HorizontalAlignment="Stretch" Background="#25A0DA" Grid.Column="0" Height="20" Padding="5,0,0,0" Margin="1" Foreground="White"/>
</Grid>
</DataTemplate>
</GroupBox.HeaderTemplate>
And this is what it looks like right now.
Take the default GroupBox Template and alter it to look the way you want
For example,
<ControlTemplate TargetType="GroupBox">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border Grid.Row="0"
BorderThickness="1"
BorderBrush="#25A0DA"
Background="#25A0DA">
<Label Foreground="White">
<ContentPresenter Margin="4"
ContentSource="Header"
RecognizesAccessKey="True" />
</Label>
</Border>
<Border Grid.Row="1"
BorderThickness="1,0,1,1"
BorderBrush="#25A0DA">
<ContentPresenter Margin="4" />
</Border>
</Grid>
</ControlTemplate>
This thread is a bit old, but someone could find this useful...
A small modification to Jakob's answer if you want to have full width header.
You can bind to the parent GroupBox, so you can use it without having a named GroupBox.
<GroupBox.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}, Path=ActualWidth }"
Background="#25A0DA" Grid.Column="0" Height="20" Padding="5,0,0,0" Margin="1" Foreground="White"/>
</DataTemplate>
</GroupBox.HeaderTemplate>
You probably will not be able to make it look exactly like your example without writing a completely different template but I gave it a simple shot by binding the width of the grid in your HeaderTemplate to the width of the groupbox and by specifying appropriate margin and padding:
<GroupBox.HeaderTemplate>
<DataTemplate>
<Grid Width="{Binding ElementName=groupBox1, Path=ActualWidth}" Margin="-10, 0, -10, 0" >
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Content="{Binding}" HorizontalAlignment="Stretch" Background="#25A0DA" Grid.Column="0" Height="20" Padding="5, 0, 0, 0" Margin="10" Foreground="White"/>
</Grid>
</DataTemplate>
</GroupBox.HeaderTemplate>
The result looks like this:
I realize this is way late, but the MahApps.Metro package has a nice GroupBox that seems to like nearly exactly like what is posted in the OP.
https://github.com/MahApps/MahApps.Metro/blob/develop/MahApps.Metro/Styles/Controls.GroupBox.xaml
Here's the Xaml from version 1.22
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls"
xmlns:Converters="clr-namespace:MahApps.Metro.Converters">
<Converters:ThicknessBindingConverter x:Key="ThicknessBindingConverter" />
<Style x:Key="MetroGroupBox" TargetType="{x:Type GroupBox}">
<Setter Property="Foreground" Value="{DynamicResource BlackBrush}" />
<Setter Property="Background" Value="{DynamicResource AccentColorBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource AccentColorBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Upper" />
<Setter Property="Controls:ControlsHelper.HeaderFontSize" Value="{DynamicResource ContentFontSize}" />
<Setter Property="Controls:GroupBoxHelper.HeaderForeground" Value="{x:Null}" />
<Setter Property="Margin" Value="5" />
<Setter Property="Padding" Value="5" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupBox}">
<Grid x:Name="GroupBoxRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Border x:Name="HeaderSite"
Grid.Row="0"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<Controls:ContentControlEx x:Name="HeaderContent"
Padding="{TemplateBinding Padding}"
FontSize="{TemplateBinding Controls:ControlsHelper.HeaderFontSize}"
FontWeight="{TemplateBinding Controls:ControlsHelper.HeaderFontWeight}"
FontStretch="{TemplateBinding Controls:ControlsHelper.HeaderFontStretch}"
Content="{TemplateBinding Header}"
ContentCharacterCasing="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(Controls:ControlsHelper.ContentCharacterCasing)}"
ContentStringFormat="{TemplateBinding HeaderStringFormat}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="False">
<TextElement.Foreground>
<MultiBinding Converter="{x:Static Converters:BackgroundToForegroundConverter.Instance}">
<Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Background"
Mode="OneWay" />
<Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="(Controls:GroupBoxHelper.HeaderForeground)"
Mode="OneWay" />
</MultiBinding>
</TextElement.Foreground>
</Controls:ContentControlEx>
</Border>
<Border Grid.Row="1"
Background="Transparent"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={StaticResource ThicknessBindingConverter}, ConverterParameter={x:Static Converters:IgnoreThicknessSideType.Top}}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
UseLayoutRounding="True">
<ContentPresenter Margin="{TemplateBinding Padding}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Cursor="{TemplateBinding Cursor}"
UseLayoutRounding="False" />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Try this :
<GroupBox BorderThickness="0" Header="BELT WEIGHER BC#1 JETTY" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="193" Width="374" OpacityMask="Black" BorderBrush="#FF1864D3" FontSize="16" FontWeight="Bold">
<GroupBox.HeaderTemplate >
<DataTemplate>
<TextBlock Text="{Binding}"
Width="357" Grid.Column="0" Padding="5,3,0,0" Margin="0,0,0,0" Foreground="White" Height="33">
<TextBlock.Background>
<LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0.968"/>
<GradientStop Color="Blue" Offset="0.828"/>
</LinearGradientBrush>
</TextBlock.Background>
</TextBlock>
</DataTemplate>
</GroupBox.HeaderTemplate>
<Border x:Name="CanvasBorder" BorderBrush="Blue" BorderThickness="1" Margin="3,0,3,0">
<Canvas Background="white" Margin="0,0,0,0" >
<Label Content="Feed Rate" Canvas.Left="10" Canvas.Top="10" FontWeight="Normal" FontSize="12"/>
<Label Content="Totalizer 1" Canvas.Left="10" Canvas.Top="35" FontWeight="Normal" FontSize="12"/>
<Label Content="Totalizer 2" Canvas.Left="10" Canvas.Top="60" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
<Label Content="Belt Load" Canvas.Left="10" Canvas.Top="85" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
<Label Content="Belt Speed" Canvas.Left="10" Canvas.Top="110" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
<TextBlock x:Name="BC1_Feedrate" HorizontalAlignment="Left" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Background="#FFF2F2FB" Width="119" FontWeight="Bold" Height="20" TextAlignment="Right" Canvas.Left="91" Canvas.Top="13" Padding="0,0,4,0"/>
<TextBlock x:Name="BC1_Totalizer1" HorizontalAlignment="Left" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Background="#FFF2F2FB" Width="119" FontWeight="Bold" Height="20" TextAlignment="Right" Canvas.Left="91" Canvas.Top="38" Padding="0,0,4,0"/>
<TextBlock x:Name="BC1_Totalizer2" HorizontalAlignment="Left" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Background="#FFF2F2FB" Width="119" FontWeight="Bold" Height="20" TextAlignment="Right" Canvas.Left="91" Canvas.Top="63" Padding="0,0,4,0"/>
<TextBlock x:Name="BC1_BeltLoad" HorizontalAlignment="Left" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Background="#FFF2F2FB" Width="119" FontWeight="Bold" Height="20" TextAlignment="Right" Canvas.Left="91" Canvas.Top="88" Padding="0,0,4,0"/>
<TextBlock x:Name="BC1_BeltSpeed" HorizontalAlignment="Left" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Background="#FFF2F2FB" Width="119" FontWeight="Bold" Height="20" TextAlignment="Right" Canvas.Left="91" Canvas.Top="113" Padding="0,0,4,0"/>
<Label Content="ton/hour" Canvas.Left="228" Canvas.Top="10" FontWeight="Normal" FontSize="12"/>
<Label Content="ton" Canvas.Left="228" Canvas.Top="35" FontWeight="Normal" FontSize="12"/>
<Label Content="ton" Canvas.Left="228" Canvas.Top="60" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
<Label Content="kg/meter" Canvas.Left="228" Canvas.Top="85" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
<Label Content="meter/second" Canvas.Left="228" Canvas.Top="110" FontWeight="Normal" FontSize="12" RenderTransformOrigin="0.516,1.808"/>
</Canvas>
</Border>
</GroupBox>

WPF - How can I place a usercontrol over an AdornedElementPlaceholder?

alt text http://img42.imageshack.us/img42/4161/blinkthru.png
I'm trying to get the validation to not show through my custom modal dialog. I've tried setting the zindex of the dialog and and of the elements in this template. Any ideas?
This is coming from a validation template:
<ControlTemplate x:Key="ValidationTemplate">
<DockPanel>
<TextBlock Foreground="Red" FontSize="20" Panel.ZIndex="-10">!</TextBlock>
<Border Name="validationBorder" BorderBrush="Red" BorderThickness="2" Padding="1" CornerRadius="3" Panel.ZIndex="-10">
<Border.Resources>
<Storyboard x:Key="_blink">
<ColorAnimationUsingKeyFrames AutoReverse="True" BeginTime="00:00:00" Storyboard.TargetName="validationBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" RepeatBehavior="Forever">
<SplineColorKeyFrame KeyTime="00:00:1" Value="#00FF0000"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Border.Resources>
<Border.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource _blink}" />
</EventTrigger>
</Border.Triggers>
<AdornedElementPlaceholder/>
</Border>
</DockPanel>
</ControlTemplate>
The dialog:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="GunMiser.Controls.PendingChangesConfirmationDialog"
Height="768" Width="1024" mc:Ignorable="d">
<Grid Background="White">
<Rectangle x:Name="MainRectangle" Margin="0,0,0,0" Style="{DynamicResource UserControlOverlayRectangleStyle}" Opacity="0.85"/>
<Border Margin="288,250,278,288" Background="#FF868686" BorderBrush="Black" BorderThickness="1">
<Border.Effect>
<DropShadowEffect Color="#FFB6B2B2"/>
</Border.Effect>
<TextBlock x:Name="textBlockMessage" Margin="7,29,7,97" TextWrapping="Wrap" d:LayoutOverrides="VerticalAlignment" TextAlignment="Center"/>
</Border>
<Button x:Name="OkButton" Click="OkButton_Click" Margin="313,0,0,328" VerticalAlignment="Bottom" Height="24" Content="Save Changes" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Left" Width="103"/>
<Button Click="CancelButton_Click" Margin="453.294,0,456,328" VerticalAlignment="Bottom" Height="24" Content="Cancel Changes" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="CancelActionButton_Click" Margin="0,0,304,328" VerticalAlignment="Bottom" Height="24" Content="Go Back" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Right" Width="114.706"/>
</Grid>
</UserControl>
And the overall window is:
<Window x:Class="GunMiser.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cal="http://www.codeplex.com/CompositeWPF"
xmlns:controls="clr-namespace:GunMiser.Controls;assembly=GunMiser.Controls"
Title="Gun Miser"
Height="768" Width="1024">
<Canvas>
<controls:PendingChangesConfirmationDialog x:Name="PendingChangesConfirmationDialog" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="1008" Height="730" Visibility="Collapsed" Panel.ZIndex="100" />
<ContentControl x:Name="FilterRegion" cal:RegionManager.RegionName="FilterRegion" Width="326" Height="656" Canvas.Top="32" VerticalAlignment="Top" HorizontalAlignment="Left" />
<ContentControl Name="WorkspaceRegion" cal:RegionManager.RegionName="WorkspaceRegion" Width="678" Height="726" Canvas.Left="330" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Click="GunsButton_Click" Width="75" Height="25" Content="Guns" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="OpticsButton_Click" Width="75" Height="25" Content="Optics" Canvas.Left="81" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="SettingsButton_Click" Width="56" Height="28" Content="Settings" Canvas.Left="944" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Button Click="AccessoriesButton_Click" Width="75" Height="25" Content="Accessories" Canvas.Left="239" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="AmmunitionButton_Click" Width="75" Height="25" Content="Ammunition" Canvas.Left="160" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
</Canvas>
</Window>
You problem is that the error template is shown in the adorner layer which in your case will be at the root window.
If you were to change your code to the following you wouldn't have a problem, because there would be a separate adorner layer created around the rest of you controls.
<Window x:Class="GunMiser.Views.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cal="http://www.codeplex.com/CompositeWPF"
xmlns:controls="clr-namespace:GunMiser.Controls;assembly=GunMiser.Controls"
Title="Gun Miser"
Height="768" Width="1024">
<Canvas>
<AdornerDecorator>
<Canvas>
<ContentControl x:Name="FilterRegion" cal:RegionManager.RegionName="FilterRegion" Width="326" Height="656" Canvas.Top="32" VerticalAlignment="Top" HorizontalAlignment="Left" />
<ContentControl Name="WorkspaceRegion" cal:RegionManager.RegionName="WorkspaceRegion" Width="678" Height="726" Canvas.Left="330" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Click="GunsButton_Click" Width="75" Height="25" Content="Guns" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="OpticsButton_Click" Width="75" Height="25" Content="Optics" Canvas.Left="81" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="SettingsButton_Click" Width="56" Height="28" Content="Settings" Canvas.Left="944" Style="{DynamicResource GunMiserButtonStyle}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Button Click="AccessoriesButton_Click" Width="75" Height="25" Content="Accessories" Canvas.Left="239" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
<Button Click="AmmunitionButton_Click" Width="75" Height="25" Content="Ammunition" Canvas.Left="160" Canvas.Top="3" Style="{DynamicResource GunMiserButtonStyle}"/>
</Canvas>
</AdornerDecorator>
<controls:PendingChangesConfirmationDialog x:Name="PendingChangesConfirmationDialog" HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="1008" Height="730" Visibility="Collapsed" Panel.ZIndex="100" />
</Canvas>
Alternatively, if you want to change just the style of the element (it's background, foreground, etc) and not it's whole ControlTemplate (which includes the adorner), you can set the Validation.ErrorTemplate so that it doesn't have a border, or exclamation point, then use a style trigger to change the style based on the property "Validation.HasError".
<Style TargetType="{x:Type TextBlock}" x:Key="TextBlockErrorStyle">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<!-- this gets rid of all adornment INCLUDING THE DEFAULT RED BORDER -->
<AdornedElementPlaceholder Name="controlWithError" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="Foreground" Value="Red"/>
<Setter Property="Background" Value="MistyRose"/>
<Setter Property="ToolTip"
Value="{Binding RelativeSource={RelativeSource Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>

Resources