how do you use TemplateBinding with a Width(double) property with a "*" or "Auto" on a new DependencyProperty?
I have a control that has a DependencyProperty that sets a width. It is a double so setting actual values works just fine. But my problem is I want to be able to set percentages and Auto but I am bombing out on it.... here is the code, the property is PanelWidth...
// other control code
public static readonly DependencyProperty PanelWidthProperty = DependencyProperty.Register("PanelWidth", typeof(double), typeof(SomeControl), null);
public double PanelWidth
{
get { return (double)GetValue(PanelWidthProperty); }
set { SetValue(PanelWidthProperty, value); }
}
// other control code
<!-- in generic.xaml -->
<Style TargetType="cyc:SomeControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="cyc:SomeControl">
<Grid x:Name="RootElement">
<Canvas x:Name="PanelElement" Width="{TemplateBinding PanelWidth}">
</Canvas>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I set 'PanelElement's Width == PanelWidth. This is fine if the PanelWidth is an actual number but not Auto(NaN) or %s.... So my question is, how do I properly create the DependencyProperty or PanelWidth property to allow for NaNs or %s?
Thanks much!
--Brad