Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The issue with Toolkits AutoCompleteBox is, they have missed to pass the ContextMenu to the inner elements of its visual tree. I have edited the template of AutoCompleteBox. Its working fine when I add TemplateBinding between ContextMenu of AutoCompleteBox and ContextMenu of TextBox inside the template of AutoCompleteBox. </p> <p>Please find the code fix: </p> <pre><code> &lt;Grid&gt; &lt;Grid.Resources&gt; &lt;Style TargetType="toolkit:AutoCompleteBox" x:Key="AutoCompleteBoxStyle"&gt; &lt;Setter Property="IsTabStop" Value="False" /&gt; &lt;Setter Property="Padding" Value="2" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="BorderBrush"&gt; &lt;Setter.Value&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FFA3AEB9" Offset="0" /&gt; &lt;GradientStop Color="#FF8399A9" Offset="0.375" /&gt; &lt;GradientStop Color="#FF718597" Offset="0.375" /&gt; &lt;GradientStop Color="#FF617584" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="Background" Value="#FFFFFFFF" /&gt; &lt;Setter Property="Foreground" Value="#FF000000" /&gt; &lt;Setter Property="MinWidth" Value="45" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="toolkit:AutoCompleteBox"&gt; &lt;Grid Opacity="{TemplateBinding Opacity}"&gt; &lt;!-- Fix for AutoCompleteBox ContextMenu - Added TemplateBinding between ContextMenu of Textbox inside template and control's ContextMenu --&gt; &lt;TextBox ContextMenu="{TemplateBinding ContextMenu}" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" IsTabStop="True" x:Name="Text" Style="{TemplateBinding TextBoxStyle}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Foreground="{TemplateBinding Foreground}" Margin="0" /&gt; &lt;Border x:Name="ValidationErrorElement" Visibility="Collapsed" BorderBrush="#FFDB000C" BorderThickness="1" CornerRadius="1"&gt; &lt;ToolTipService.ToolTip&gt; &lt;ToolTip x:Name="validationTooltip" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Template="{DynamicResource CommonValidationToolTipTemplate}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"&gt; &lt;ToolTip.Triggers&gt; &lt;EventTrigger RoutedEvent="Canvas.Loaded"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsHitTestVisible"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;sys:Boolean&gt;true&lt;/sys:Boolean&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/ToolTip.Triggers&gt; &lt;/ToolTip&gt; &lt;/ToolTipService.ToolTip&gt; &lt;Grid Height="12" HorizontalAlignment="Right" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12" Background="Transparent"&gt; &lt;Path Fill="#FFDC000C" Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" /&gt; &lt;Path Fill="#ffffff" Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8" /&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;Popup x:Name="Popup"&gt; &lt;Grid Opacity="{TemplateBinding Opacity}" Background="{TemplateBinding Background}" &gt; &lt;Border x:Name="PopupBorder" HorizontalAlignment="Stretch" Opacity="0" BorderThickness="0"&gt; &lt;Border.RenderTransform&gt; &lt;TranslateTransform X="1" Y="1" /&gt; &lt;/Border.RenderTransform&gt; &lt;Border.Background&gt; &lt;SolidColorBrush Color="#11000000" /&gt; &lt;/Border.Background&gt; &lt;Border HorizontalAlignment="Stretch" Opacity="1.0" Padding="0" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="0"&gt; &lt;Border.RenderTransform&gt; &lt;TransformGroup&gt; &lt;TranslateTransform X="-1" Y="-1" /&gt; &lt;/TransformGroup&gt; &lt;/Border.RenderTransform&gt; &lt;Border.Background&gt; &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt; &lt;GradientStop Color="#FFDDDDDD" Offset="0" /&gt; &lt;GradientStop Color="#AADDDDDD" Offset="1" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Border.Background&gt; &lt;ListBox x:Name="Selector" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemContainerStyle="{TemplateBinding ItemContainerStyle}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" BorderThickness="0" ItemTemplate="{TemplateBinding ItemTemplate}" /&gt; &lt;/Border&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/Popup&gt; &lt;vsm:VisualStateManager.VisualStateGroups&gt; &lt;vsm:VisualStateGroup x:Name="PopupStates"&gt; &lt;vsm:VisualStateGroup.Transitions&gt; &lt;vsm:VisualTransition GeneratedDuration="0:0:0.1" To="PopupOpened" /&gt; &lt;vsm:VisualTransition GeneratedDuration="0:0:0.2" To="PopupClosed" /&gt; &lt;/vsm:VisualStateGroup.Transitions&gt; &lt;vsm:VisualState x:Name="PopupOpened"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" To="1.0" Duration="0:0:0.1" /&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;vsm:VisualState x:Name="PopupClosed"&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="PopupBorder" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.2" /&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt; &lt;vsm:VisualStateGroup x:Name="ValidationStates"&gt; &lt;vsm:VisualState x:Name="Valid" /&gt; &lt;vsm:VisualState&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;Visibility&gt;Visible&lt;/Visibility&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;vsm:VisualState x:Name="InvalidFocused"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;Visibility&gt;Visible&lt;/Visibility&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0"&gt; &lt;DiscreteObjectKeyFrame.Value&gt; &lt;sys:Boolean&gt;True&lt;/sys:Boolean&gt; &lt;/DiscreteObjectKeyFrame.Value&gt; &lt;/DiscreteObjectKeyFrame&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/vsm:VisualState&gt; &lt;/vsm:VisualStateGroup&gt; &lt;/vsm:VisualStateManager.VisualStateGroups&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/Grid.Resources&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;/Grid.RowDefinitions&gt; &lt;toolkit:AutoCompleteBox Style="{DynamicResource AutoCompleteBoxStyle}"&gt; &lt;toolkit:AutoCompleteBox.ContextMenu&gt; &lt;ContextMenu&gt; &lt;MenuItem Header="Menu Item 1"&gt;&lt;/MenuItem&gt; &lt;MenuItem Header="Menu Item 2"&gt;&lt;/MenuItem&gt; &lt;/ContextMenu&gt; &lt;/toolkit:AutoCompleteBox.ContextMenu&gt; &lt;/toolkit:AutoCompleteBox&gt; &lt;TextBox Grid.Row="1" &gt; &lt;TextBox.ContextMenu&gt; &lt;ContextMenu&gt; &lt;MenuItem Header="Menu Item 1"&gt;&lt;/MenuItem&gt; &lt;MenuItem Header="Menu Item 2"&gt;&lt;/MenuItem&gt; &lt;/ContextMenu&gt; &lt;/TextBox.ContextMenu&gt; &lt;/TextBox&gt; &lt;/Grid&gt; </code></pre> <p>Regards, Abdul Rahman A.H.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload