FYI Analyzing source code of WPF examples by Infragistic and Microsoft

DracoConstellation

New member
Joined
Jun 17, 2016
Messages
2
Programming Experience
5-10
Good day.
WPF is such a unique thing that despite the fact that it is super simple sometime is really confusing (this forum branch is another proof of it)
Interestingly enough, even huge companies have a lot of kludges when developing WPF applications. Even in their own examples which seems to be perfectly polished.
For example, Infragistics company writes the following:
In the "IGExtensions.Common.WPF" project, in the file "LambertConformalConic.cs" we saw the following string of "DependencyProperty" registration:
C#:
public static readonly DependencyProperty CentralMeridianProperty
 = DependencyProperty.Register("CentralMeridianProperty",
                               typeof(double), 
                               typeof(LambertConformalConic),
                               new PropertyMetadata(0.0, new PropertyChangedCallback(UpdateConstants)));
To write/read in the dependency property from the C# code, the programmers create the following property:
C#:
public double CentralMeridian {
  get { return (double)GetValue(CentralMeridianProperty);  }
  set { SetValue(CentralMeridianProperty, value); } 
}
or
C#:
public static readonly DependencyProperty
 AxisFinancialIndicatorYTemplateProperty =
  DependencyProperty.Register("AxisFinancialIndicatorYTemplate",
    typeof(DataTemplate),
    typeof(DataChartEx),
    new PropertyMetadata(default(DataTemplate)));

public DataTemplate AxisCategoryYTemplate{
 get { return (DataTemplate)
  GetValue(AxisFinancialIndicatorYTemplateProperty); }
 set { 
  SetValue(AxisFinancialIndicatorYTemplateProperty, value); }
}
Infragistics steps on the same rake by creating a property with the "AxisCategoryYTemplate" name, instead of the registered name "AxisFinancialIndicatorYTemplate".
Read more here: Analyzing source code of WPF examples by the Infragistics Company

Even Microsoft itself has quite a number of errors.
For example.
C#:
public double Radius
{
  get { return (double) GetValue(RadiusProperty); }
  set { SetValue(RadiusProperty, value); }
}
public static readonly DependencyProperty 
  RadiusProperty = DependencyProperty.Register(
    "RadiusBase",
    typeof (double),
    typeof (FireworkEffect),
    new FrameworkPropertyMetadata(15.0));
In this particular case, the name that is registered for a dependency property does not match the name of the wrapper property to access the DependencyProperty from the code. This option causes big problems when working from XAML markup. WPF allows from XAML access a simple property Radius and read the value from it, but the changes of this property won't get fetched from XAML.

Read more here: Source code of WPF samples by Microsoft was checked
 
Back
Top Bottom