ResizableContentControl as resource for PopupButton.PopupContent

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 10 years ago by Daniel Barta
Version: 13.2.0592
Avatar

Hello,


is it possible to use ResizableContentControl as resources for PopupButton.PopupContent for more than one PopupButton ? The following example fails with the exception:

'Set property 'ActiproSoftware.Windows.Controls.PopupButton.PopupContent' threw an exception.' Line number '22' and line position '64'."
"Specified element is already the logical child of another element. Disconnect it first."

Thank you,

Daniel Barta

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
Title="MainWindow" Height="100" Width="100">
<Grid>

<Grid.Resources>
<shared:ResizableContentControl CanAutoSize="True" ResizeMode="None" BorderThickness="1" x:Key="popupContent">
<TextBlock>Test</TextBlock>
</shared:ResizableContentControl>
</Grid.Resources>

<shared:PopupButton x:Name="popup1" Grid.Column="0" Grid.Row="0" Margin="2" DisplayMode="PopupOnly" StaysOpen="False" MinHeight="16"
Background="LightGray" AutomationProperties.AutomationId="ColorPickerEditor.PopupButton"
HorizontalAlignment="Left" VerticalAlignment="Top" Width="16" Height="20"
PopupContent="{StaticResource popupContent}">
</shared:PopupButton>

<shared:PopupButton x:Name="popup2" Grid.Column="1" Grid.Row="0" Margin="2" DisplayMode="PopupOnly" StaysOpen="False" MinHeight="16"
Background="LightGray" AutomationProperties.AutomationId="ColorPickerEditor.PopupButton" HorizontalAlignment="Right"
VerticalAlignment="Top" Width="16" Height="20"
PopupContent="{StaticResource popupContent}">
</shared:PopupButton>

</Grid>
</Window>

Comments (1)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

You can't do that sort of thing with WPF controls because you are effectively trying to reuse your single ResizableContentControl instance that is in the Resources within two different PopupButton controls.  Instead, you would need to use the PopupContentTemplate property and supply a DataTemplate that had the ResizableContentControl in it.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.