Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Page()
- {
- InitializeComponent();
- InitializeOther();
- }
- private DoubleCollection dashes;
- public DoubleCollection Dashes
- {
- get
- {
- //dashes = new DoubleCollection(); //works ok
- //dashes.Add(2.0);
- //dashes.Add(2.0);
- if (dashes == null)
- {
- dashes = new DoubleCollection(); //causes exception
- dashes.Add(2.0);
- dashes.Add(2.0);
- }
- return dashes;
- }
- set
- {
- dashes = value;
- }
- }
- private void InitializeOther()
- {
- Line line;
- for (int i = 0; i < 10; i++)
- {
- line = new Line();
- line.Stroke = new SolidColorBrush(Colors.Blue);
- line.StrokeDashArray = Dashes; //exception thrown here
- line.X1 = 10;
- line.Y2 = 10;
- line.X2 = 400;
- line.Y2 = 10 + (i * 40);
- canvas1.Children.Add(line);
- }
- }
- line = new Line();
- line.Stroke = new SolidColorBrush(Colors.Blue);
- line.StrokeDashArray = **new DoubleCollection() { 2.0, 2.0 };**
- line.X1 = 10;
- ...
Add Comment
Please, Sign In to add comment