Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot see Custom WPF Control in Designer in VS2010
    primarykey
    data
    text
    <p>I'm experiencing a very strange issue where I cannot see a Custom WPF control in the visual studio designer (as if it cannot find the appropriate style) but the Style shows up correctly in the Property grid under the Style property showing Key: Default at the bottom and also showing a picture of my Control styled correctly with Content and Text set appropriately.</p> <p>I guess my question is pretty obvious, but if my control is able to find the style in the property grid, why doesn't it show up properly in the designer?</p> <p>My style is declared in the Themes/Generic.xaml file and I am calling <code>DefaultStyleKeyProperty.OverrideMetadata(typeof(DragDockPanel), new FrameworkPropertyMetadata(typeof(DragDockPanel)));</code> in the static constructor of my control. However, I notice that my overridden function of <code>OnApplyTemplate()</code> isn't getting called at all.</p> <p>Here is my style located in Generic.xaml:</p> <pre><code>&lt;Style TargetType="local:DragDockPanel"&gt; &lt;Setter Property="Background" Value="#ff000000" /&gt; &lt;Setter Property="BorderBrush" Value="#ff333333" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:DragDockPanel"&gt; &lt;Grid&gt; &lt;local:OuterGlowBorder OuterGlowOpacity="0.4" OuterGlowSize="15" CornerRadius="3,3,3,3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"&gt; &lt;local:InnerGlowBorder InnerGlowOpacity="1" CornerRadius="3,3,3,3" InnerGlowColor="#11ffffff" InnerGlowSize="15,15,0,0" Margin="0" Padding="2" ClipContent="True" Background="Transparent" BorderThickness="0"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" /&gt; &lt;Border Background="#7f000000" Margin="-2" Padding="3"&gt; &lt;Grid&gt; &lt;Border x:Name="GripBarElement" CornerRadius="3,3,0,0" Background="#00ffffff" VerticalAlignment="Top" MinHeight="30" Cursor="Hand" Margin="0,0,32,0" IsHitTestVisible="{TemplateBinding DraggingEnabled}"&gt; &lt;Grid&gt; &lt;Rectangle Opacity="0.5"&gt; &lt;Rectangle.Fill&gt; &lt;LinearGradientBrush EndPoint="6.58300018310547,6.08300018310547" StartPoint="2.31500005722046,1.81500005722046" SpreadMethod="Repeat" MappingMode="Absolute"&gt; &lt;GradientStop Color="#FFAFAFAF" Offset="0" /&gt; &lt;GradientStop Color="#00FFFFFF" Offset="1" /&gt; &lt;GradientStop Color="#00FFFFFF" Offset="0.339" /&gt; &lt;/LinearGradientBrush&gt; &lt;/Rectangle.Fill&gt; &lt;/Rectangle&gt; &lt;ContentPresenter Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" /&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;ToggleButton x:Name="MaximizeToggleButton" VerticalAlignment="Top" HorizontalAlignment="Right" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, Path=IsMaximized}" Margin="0,5,5,0" Width="20" Height="20" Cursor="Hand"&gt; &lt;ToggleButton.Template&gt; &lt;ControlTemplate TargetType="ToggleButton"&gt; &lt;Border Background="#7F000000" CornerRadius="2,2,2,2"&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="FocusStates"&gt; &lt;VisualState x:Name="Focused" /&gt; &lt;VisualState x:Name="Unfocused" /&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualState x:Name="Disabled" /&gt; &lt;VisualState x:Name="Normal" /&gt; &lt;VisualState x:Name="MouseOver"&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.6" /&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0.3" /&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Pressed"&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.Opacity)"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.15" /&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="CheckStates"&gt; &lt;VisualState x:Name="Checked"&gt; &lt;Storyboard&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="checkedArrow" Storyboard.TargetProperty="(UIElement.Opacity)"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1" /&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="uncheckedArrow" Storyboard.TargetProperty="(UIElement.Opacity)"&gt; &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" /&gt; &lt;/DoubleAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unchecked"&gt; &lt;Storyboard /&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Indeterminate" /&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;Grid Height="Auto" Width="Auto"&gt; &lt;Border Margin="0,0,0,0" BorderBrush="#FFFFFFFF" BorderThickness="1,1,1,1" CornerRadius="1,1,1,1" Width="16" Height="16"&gt; &lt;Grid&gt; &lt;Path HorizontalAlignment="Right" Margin="0,1.24500000476837,1.70700001716614,5.375" x:Name="uncheckedArrow" VerticalAlignment="Stretch" Width="6.752" Stretch="Fill" Stroke="#FFFFFFFF" Data="M0.5,1.005 L6.2509999,1.005 M6.25,6.8800006 L6.25,0.5 M6.2520003,1.0880001 L0.50000024,6.8800001" /&gt; &lt;Path HorizontalAlignment="Stretch" Margin="1.45899999141693,5.74200010299683,5.78900003433228,0.878000020980835" x:Name="checkedArrow" VerticalAlignment="Stretch" Stretch="Fill" Stroke="#FFFFFFFF" Data="M0.5,1.005 L6.2509999,1.005 M6.25,6.8800006 L6.25,0.5 M6.2520003,1.0880001 L0.50000024,6.8800001" Opacity="0" RenderTransformOrigin="0.5,0.5"&gt; &lt;Path.RenderTransform&gt; &lt;TransformGroup&gt; &lt;ScaleTransform /&gt; &lt;SkewTransform /&gt; &lt;RotateTransform Angle="180" /&gt; &lt;TranslateTransform /&gt; &lt;/TransformGroup&gt; &lt;/Path.RenderTransform&gt; &lt;/Path&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;Rectangle Fill="#FFFFFFFF" RadiusX="2" RadiusY="2" Margin="1,1,1,1" Opacity="0" x:Name="rectangle" /&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/ToggleButton.Template&gt; &lt;/ToggleButton&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/local:InnerGlowBorder&gt; &lt;/local:OuterGlowBorder&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="HeaderTemplate"&gt; &lt;Setter.Value&gt; &lt;DataTemplate&gt; &lt;local:DropShadowTextBlock Text="{Binding}" FontFamily="Verdana" FontSize="14" VerticalAlignment="Center" Margin="5" DropShadowDistance="3" DropShadowAngle="45" Foreground="#ffffffff" /&gt; &lt;/DataTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>This control uses other Custom controls as well, which are all declared in Generic.xaml, and have their DefaultStyleKeyProperty set. If you want me to post the styles for these custom controls I can, but for brevifty I have left them out.</p> <p>Here's how I'm calling the control:</p> <pre><code>&lt;bl:DragDockPanelHost x:Name="dragDockPanelTest" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Visible" Margin="0,0,0,0"&gt; &lt;bl:DragDockPanel Name="Test1" Header="TEST" Content="WHERE AM I?" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Visible"&gt; &lt;/bl:DragDockPanel&gt; &lt;/bl:DragDockPanelHost&gt; </code></pre> <p>Any help would be greatly appreciated, I'm completely out of ideas at this point. Thanks!</p> <p>Edit:</p> <p>Here's some more info that may help; I added a style for the DragDropPanelHost to my Generic.xaml which very simply changes the canvas Background color. However, the background color does not change on the DragDropPanelHost in the designer (after recompiling etc.).</p> <p>Here's the style:</p> <pre><code>&lt;Style TargetType="local:DragDockPanelHost"&gt; &lt;Setter Property="ItemsPanel"&gt; &lt;Setter.Value&gt; &lt;ItemsPanelTemplate&gt; &lt;Canvas Background="BLUE"&gt; &lt;/Canvas&gt; &lt;/ItemsPanelTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>It seems something is very messed up here...For some reason the Styles aren't loading at all...</p>
    singulars
    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.
 

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