I've set up a custom control in SL and I'm trying to get the default look of the control to behave properly. I feel (with the help of some smart folks on here) that I am getting pretty close to getting this, but I'm still not quite there yet.
When my control is first added to a panel in Blend, it shows up as I expect based on the template, and when I modify the dependency properties I've exposed, those work fine as well. The problem I'm having now is that when make a change through Blend and then "reset" that value using the options box, it resets the property under the Miscellaneous pane, but doesn't actually change the control itself in the design view unless I build the project again.
Here's the code I currently have:
public enum SolidGlossTypes
{
Normal,
Header,
Footer,
None
}
public SolidGlossTypes SolidGlossType
{
get
{
return (SolidGlossTypes)GetValue(SolidGlossTypeProperty);
}
set
{
SetValue(SolidGlossTypeProperty, value);
switch (value)
{
case SolidGlossTypes.Header:
SolidGloss_Upper.Visibility = Visibility.Visible;
SolidGloss_Lower.Visibility = Visibility.Collapsed;
break;
case SolidGlossTypes.Footer:
SolidGloss_Upper.Visibility = Visibility.Collapsed;
SolidGloss_Lower.Visibility = Visibility.Visible;
break;
case SolidGlossTypes.None:
SolidGloss_Upper.Visibility = Visibility.Collapsed;
SolidGloss_Lower.Visibility = Visibility.Collapsed;
break;
default:
SolidGloss_Upper.Visibility = Visibility.Visible;
SolidGloss_Lower.Visibility = Visibility.Visible;
break;
}
}
}
public static readonly DependencyProperty SolidGlossTypeProperty = DependencyProperty.Register("SolidGlossType", typeof(SolidGlossTypes), typeof(SolidGloss), new PropertyMetadata(SolidGlossTypes.Normal));
I've tried tinkering with a property changed callback but haven't had any success getting it to work.
Also, is it possible to set the default values of a dependency property to a style within generic.xaml and then bind to that from the template?
Thanks in advance,
E