[C# Markup] TemplateBind to PathFigure.StartPoint and LineSegment.Point crashes #2405
-
Create a simple Control that uses public MyControl()
{
DefaultStyleKey = typeof(MyControl);
Style = new Style<MyControl>().Setters(s => s.Template(
ctrl => new Path()
.Stroke(Colors.Blue)
.StrokeThickness(3)
.Data(new PathGeometry().Figures(new PathFigureCollection()
{
new PathFigure()
//.StartPoint(new Point(10, 30)) // works fine
.StartPoint(x => x.TemplateBind(() => ctrl.StartHotspot)) // crashes
.Segments(new PathSegmentCollection()
{
new LineSegment()
//.Point(new Point(80, 50)) // works fine
.Point(x => x.TemplateBind(() => ctrl.EndHotspot)) // crashes
})
})))
);
}
#region StartHotspot
public Point StartHotspot
{
get { return (Point)GetValue(StartHotspotProperty); }
set { SetValue(StartHotspotProperty, value); }
}
public static readonly DependencyProperty StartHotspotProperty =
DependencyProperty.Register(
nameof(StartHotspot),
typeof(Point),
typeof(MyControl),
new PropertyMetadata(new Point(0, 0)));
#endregion
#region EndHotspot
public Point EndHotspot
{
get { return (Point)GetValue(EndHotspotProperty); }
set { SetValue(EndHotspotProperty, value); }
}
public static readonly DependencyProperty EndHotspotProperty =
DependencyProperty.Register(
nameof(EndHotspot),
typeof(Point),
typeof(MyControl),
new PropertyMetadata(new Point(0, 0)));
#endregion The control is now consumed in a frame: public MainPage() => this
.DataContext(new BindableMainPageModel(), (page, vm) => page
.Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
.Content(new StackPanel()
.VerticalAlignment(VerticalAlignment.Center)
.HorizontalAlignment(HorizontalAlignment.Center)
.Children(
new TextBlock()
.Text("Hello Uno Platform!"),
// implementing Path directly works fine:
new Path()
.Stroke(Colors.DarkGreen)
.StrokeThickness(3)
.Data(new PathGeometry().Figures(new PathFigureCollection()
{
new PathFigure()
.StartPoint(new Point(10,10))
.Segments(new PathSegmentCollection() {
new LineSegment()
.Point(new Point(80,30))
})
})),
// implementing Path bound to MVU model works fine:
new Path()
.Stroke(Colors.HotPink)
.StrokeThickness(3)
.Data(new PathGeometry().Figures(new PathFigureCollection()
{
new PathFigure()
.StartPoint(() => vm.StartPoint)
.Segments(new PathSegmentCollection() {
new LineSegment()
.Point(() => vm.EndPoint)
})
})),
// implementing Path inside MyControl bound to control's properties fails:
new MyControl()
.StartHotspot(new Point(10, 30))
.EndHotspot(new Point(80, 50))
))); Environment:
repro: UnoPathApp.zip |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Please @dansiegel can you investigate this one as well? |
Beta Was this translation helpful? Give feedback.
-
Converted this discussion into an issue #2406, let's track the progress there |
Beta Was this translation helpful? Give feedback.
Converted this discussion into an issue #2406, let's track the progress there