我希望有一个按钮,单击该按钮时会显示一个下拉菜单。
到目前为止,我有这个:
<dx:SimpleButton Padding="1" Margin="1" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch"
Command="{Binding CreateItem}" >
<DockPanel HorizontalAlignment="Stretch" LastChildFill="True">
<Image DockPanel.Dock="Left" Width="16" Height="16" Source="../Resources/Add.png" Margin="10" />
<dx:SimpleButton Name="DropDownButton" DockPanel.Dock="Right" Padding="1" Margin="0,1,1,1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
<dx:SimpleButton.Content>
<Image Width="16" Height="16" Source="../Resources/customDropDown.png" />
</dx:SimpleButton.Content>
<dx:SimpleButton.ContextMenu>
<ContextMenu x:Name="DropDownMenu" PlacementRectangle="{Binding RelativeSource={RelativeSource Self}}">
<MenuItem Command="{Binding PasteItem}" Header="Paste" />
</ContextMenu>
</dx:SimpleButton.ContextMenu>
<dx:SimpleButton.Triggers>
<EventTrigger SourceName="DropDownButton" RoutedEvent="Button.Click">
<BeginStoryboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DropDownMenu" Storyboard.TargetProperty="(ContextMenu.IsOpen)">
<DiscreteObjectKeyFrame KeyTime="0:0:0">
<DiscreteObjectKeyFrame.Value>
<system:Boolean>True</system:Boolean>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</dx:SimpleButton.Triggers>
</dx:SimpleButton>
<TextBlock VerticalAlignment="Center" Text="{Binding Path=Slot.Name}" />
</DockPanel>
</dx:SimpleButton>
但是当我单击按钮时,出现此错误:
'DropDownMenu' name cannot be found in the name scope of 'DevExpress.Xpf.Core.SimpleButton'.
我想念什么?