【发布时间】:2019-01-05 21:50:04
【问题描述】:
我正在尝试在 StackLayout 的自定义渲染器中插入 UWP 特定子级。
但是,在下面的示例代码中,Control 始终是 null,而我的 StackLayout 有孩子。也许StackPanel 不是StackLayout 在UWP 中呈现的内容。
public class MyRenderer : ViewRenderer<StackLayout, StackPanel>
{
private bool _childAdded;
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!_childAdded && Control?.Children != null)
{
_childAdded = true;
Control.Children.Insert(0, new Windows.UI.Xaml.Shapes.Rectangle());
}
base.OnElementPropertyChanged(sender, e);
}
}
【问题讨论】:
标签: xamarin.forms uwp