How to get the value of an inherited FontSize property in an UserControl?

You can bind your FontSize property to the FontSize property of your UserControl and use a converter to do the ratio.

Up vote 0 down vote favorite share g+ share fb share tw.

I am working on Windows Phone 7.1 application. I have a UserControl which has a bunch Silverlight child controls. The font sizes for most of these child controls can be same as that of the host of the said UserControl (which will anyway get inherited from the host).

However for one of the child controls, I want to set the FontSize to half the FontSize of the UserControl. And I want it to update if the FontSize of the host changes. But now during the UserControl design time, since there is no host, I am unable make this work.

Doing something like 0.5*FontSize results in some default value of FontSize and it does not get updated when the FontSize changes. What should I be doing to make it work? Wpf silverlight windows-phone-7 link|improve this question asked Nov 5 '11 at 18:21bharath72.

You can bind your FontSize property to the FontSize property of your UserControl and use a converter to do the ratio. Here's a sample with a textblock inside a page: And the converter (declared as a resource in the App. Xaml file: public class FontSizeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var valueToConvert = value == null?

0 : System.Convert. ToDouble(value); return valueToConvert * 0.5; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException("no use"); } }.

I got it working by implementing the way you suggested. Thank You. – bharath Nov 8 '11 at 16:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions