我創建了一個自定義視圖,我想通過系結來設定它的內容。這就是我所擁有的:
<ContentView.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<ffimageloadingsvg:SvgCachedImage Source="resource://CTP.SVG.exit.svg"
Grid.Row="0" Grid.Column="1"
HeightRequest="30"
WidthRequest="30"
HorizontalOptions="Center"
VerticalOptions="Center">
</ffimageloadingsvg:SvgCachedImage>
<redefinitions:BindableView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Content="{Binding View, Source={x:Reference this}, Mode=OneWay}"/>
</Grid>
</ContentView.Content>
在本教程之后,我定義了我的 BindableView:
[ContentProperty(nameof(Content))]
public class BindableView : View
{
public static readonly BindableProperty ContentProperty =
BindableProperty.Create(
propertyName: nameof(Content),
returnType: typeof(View),
declaringType: typeof(BindableView),
defaultValue: default(View));
public View Content
{
get { return (View)GetValue(ContentProperty); }
set { SetValue(ContentProperty, value); }
}
}
但是 BindableView 永遠不會顯示,即使我靜態定義了它的內容。我錯過了什么?
uj5u.com熱心網友回復:
解決它的最簡單方法是使用ContentView而不是自定義BindableView。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/404811.html
標籤:
