如何在中使用TextCell设置填充/边距来设置Xamarin.Forms高度?
我尝试在本机项目中遵循自定义渲染器:
class CustomTextCellRenderer : TextCellRenderer
{
public override Windows.UI.Xaml.DataTemplate GetTemplate(Cell cell)
{
var d = base.GetTemplate(cell);
//Set something here???
return d;
}
}但找不到任何要设置的财产。
有一个函数来设置DataTemplate的依赖属性,但我无法确定它,那么需要设置的高度依赖属性名是什么?
d.SetValue(???DependencyProperty???, value);发布于 2016-07-07 22:24:58
由于TextCell是内置的单元格,因此对其进行了优化,并设计为按原样使用。但是,您可以基于DataTemplate模板创建一个自定义TextCell,然后返回该模板。
您可以在Xamarin.Forms 来源中找到原始模板。然后,在UWP平台项目的App.xaml中,用不同的键在ResourceDictionary中定义新的DataTemplate:
<DataTemplate x:Key="MyTextCell">
<StackPanel Background="Aqua">
<TextBlock
Padding="0 10 0 10"
Margin="5"
Text="{Binding Text}"
Style="{ThemeResource BaseTextBlockStyle}" />
<TextBlock
Text="{Binding Detail}"
Style="{ThemeResource BodyTextBlockStyle}"
x:Name="detail"/>
</StackPanel>
</DataTemplate>并在自定义呈现器中访问它:
return App.Current.Resources["MyTextCell"] as Windows.UI.Xaml.DataTemplate;https://stackoverflow.com/questions/38181937
复制相似问题