Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight 4 custom control child items style
    text
    copied!<p>I have custom control where i want to show some items. In generic.xaml defined style for custom control:</p> <pre><code> &lt;Style TargetType="local:Custom"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="local:Customl"&gt; &lt;!-- Root Grid--&gt; &lt;Grid x:Name="CustomLayout" Background="Black"&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>And i set to C#</p> <pre><code> [TemplatePart(Name = "CustomLayout", Type = typeof(Grid))] [StyleTypedProperty(Property = "ChildItemStyle", StyleTargetType = typeof(Control))] public class GaugeControl : Control </code></pre> <p>Everything working fine excepts style for child items defined in generic.xaml:</p> <pre><code> &lt;Style TargetType="{x:Type Control}"&gt; &lt;Setter Property="Background" Value="Red"&gt;&lt;/Setter&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Control}"&gt; &lt;!-- Root Grid--&gt; &lt;Grid x:Name="LayoutRoot" Background="Red"&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Custom control with attribute</p> <pre><code> [StyleTypedProperty(Property = "ChildItemStyle", StyleTargetType = typeof(Control))] </code></pre> <p>And i have ChildItemStyle DependencyProperty in my custom control but its always null.</p> <p>How can i get this Style property and whats wrong i am doing?</p>
 

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