Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Defaulting ContentPresenter Content
    primarykey
    data
    text
    <p>Why won't this work?</p> <p>In <em>generic.xaml</em> for a custom control:</p> <p>In the style applied to the custom control...</p> <pre><code>&lt;Setter Property="ChromeContent"&gt; &lt;Setter.Value&gt; &lt;Grid /&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; </code></pre> <p>...</p> <p>Later, in the control template...</p> <pre><code>&lt;ContentPresenter Grid.Column="0" x:Name="ChromeContentPresenter" Content="{TemplateBinding ChromeContent}" /&gt; </code></pre> <p>Here's the dependency property for ChromeContent...</p> <pre><code>public Object ChromeContent { get { return (Object)GetValue(ChromeContentProperty); } set { SetValue(ChromeContentProperty, value); } } public static readonly DependencyProperty ChromeContentProperty = DependencyProperty.Register("ChromeContent", typeof(Object), typeof(casPopup), null); </code></pre> <p>As you can see, it takes any object. I tried changing it to a Grid, but that did not help.</p> <p>It throws this error (from javascript): _Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'</p> <p>Oddly, the following will work fine if I remove the Grid from the setter nd just use text:</p> <pre><code>&lt;Setter Property="ChromeContent" Value="DEFAULT" /&gt; </code></pre> <p>Also, this will work too from the OnApplyTemplate method in the control class:</p> <pre><code> Grid g = new Grid(); g.Width = 100; g.Height = 25; g.Background = new SolidColorBrush(Colors.LightGray); ChromeContent = g; </code></pre> <p>I'm having a hard time understanding what is preventing the default content of a grid, defined in the generic.xaml from working. Does anyone have any knowledge on this matter?</p> <p>Many thanks in advance for your help!</p>
    singulars
    1. This table or related slice is empty.
    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