Accessing Style setters in Unity C#
Posted: 28 Oct 2014, 21:51
What is the correct way to access the setter value strings in Unity C#?
<Style x:Key="SampleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Regular"></Setter>
<Setter Property="FontSize" Value="18"></Setter>
</Style>
var style = FindResource<Noesis.Style>("SampleStyle");
var setters = style.GetSetters();
for (int i = 0; i < setters.Count(); i++)
{
var setter = setters.Get((uint)i).As<Setter>();
Debug.Log(string.Format("{0}: {1} {2}",setter.GetProperty().GetName(),setter.GetValue().GetType(), setter.GetTargetName()));
}
When I call setter.GetValue I get a Noesis.BaseComponent. I am interested in getting the value of 18 for font size in code.
Thanks
<Style x:Key="SampleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Regular"></Setter>
<Setter Property="FontSize" Value="18"></Setter>
</Style>
var style = FindResource<Noesis.Style>("SampleStyle");
var setters = style.GetSetters();
for (int i = 0; i < setters.Count(); i++)
{
var setter = setters.Get((uint)i).As<Setter>();
Debug.Log(string.Format("{0}: {1} {2}",setter.GetProperty().GetName(),setter.GetValue().GetType(), setter.GetTargetName()));
}
When I call setter.GetValue I get a Noesis.BaseComponent. I am interested in getting the value of 18 for font size in code.
Thanks