I'm begginer in Silverlight and I have next code:
private void btnAdd_Click_2(object sender, RoutedEventArgs e)
{
string xmlns = "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"";
string xmlnsx = "xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"";
string pathXaml =
String.Format("<Path {0} {1} Data=\"{2}\" />", xmlns, xmlnsx,this.Resour开发者_JAVA百科ces[txt.Text].ToString());
Path p1 = (Path)System.Windows.Markup.XamlReader.Load(pathXaml);
//p1.Width == NaN ??????
}
Can somebody explain to me why p1.Width is NaN?
Thanks, Viktor
Path inherits from FrameworkElement and there the default value is set to Double.NaN (http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.width(v=vs.95).aspx). If you want to get the current width, use the ActualWidth Property of the path. This is the width of the currently rendered Path.
BR,
TJ
精彩评论