Добрый вечер,
Я пытаюсь оформить ToggleButton с помощью всплывающего окна. К сожалению, он говорит мне: «Контент установлен более одного раза». (StackPanel для дочерних элементов есть)
Шаблон XAML:
<Style x:Key="DropDownToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{StaticResource B_menubar}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Height="40" Width="100" Background="{TemplateBinding Background}">
<ContentPresenter/>
<Popup StaysOpen="false" IsOpen="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="Slide" x:Name="Popup">
<Border>
<Grid x:Name="SubMenu1">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Background="#FF080808">
<Button/>
<Button/>
<Button/>
</StackPanel>
</Grid>
</Border>
</Popup>
</StackPanel>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsOpen, ElementName=Popup}" Value="True">
<Setter Property="IsHitTestVisible" Value="False"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Код ошибки XAML:
<Grid Grid.Column="5">
<ToggleButton x:Name="TogglePopupButton" Content="My Popup Toggle Button" Width="100" Style="{StaticResource DropDownToggleButton}">
<Button/>
<Button/>
<!-- Content is set more than once-->
</ToggleButton>
</Grid>