Why is this not working?
In generic.xaml for a custom control:
In the style that applies to a custom control ...
<Setter Property="ChromeContent">
<Setter.Value>
<Grid />
</Setter.Value>
</Setter>
...
Later, in the control template ...
<ContentPresenter Grid.Column="0"
x:Name="ChromeContentPresenter"
Content="{TemplateBinding ChromeContent}" />
Here's the dependency property for ChromeContent ...
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);
As you can see, it accepts any object. I tried changing it to a Grid, but that didn't help.
It throws this error (from javascript): _Failed to assign to the 'System.Windows.Controls.ContentPresenter.Content' property
Oddly enough, the following will work fine if I remove the grid from the setter and just use the text:
<Setter Property="ChromeContent" Value="DEFAULT" />
In addition, this will also work with the OnApplyTemplate method in the management class:
Grid g = new Grid();
g.Width = 100;
g.Height = 25;
g.Background = new SolidColorBrush(Colors.LightGray);
ChromeContent = g;
Itβs hard for me to understand what prevents the standard contents of the grid defined in generic.xaml from working. Does anyone know about this?
!