当 PivotItem 声明为:
<phone:Pivot Margin="50,0,50,0">
<phone:PivotItem Margin="0">
<TextBlock>Text</TextBlock>
</phone:PivotItem>
</phone:Pivot>
但是我在使用绑定(bind)的时候如何设置Margin:
<phone:Pivot Margin="50,0,50,0">
<phone:Pivot.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Body}"/>
</DataTemplate>
</phone:Pivot.ItemTemplate>
</phone:Pivot>
如何在 DataTemplate 上设置边距?
最佳答案
您可以尝试使用如下样式:
<phone:Pivot Margin="50,0,50,0">
<phone:Pivot.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Body}"/>
</DataTemplate>
</phone:Pivot.ItemTemplate>
<phone:Pivot.ItemContainerStyle>
<Style TargetType="phone:PivotItem">
<Setter Property="Margin" Value="0"/>
</Style>
</phone:Pivot.ItemContainerStyle>
</phone:Pivot>
关于xaml - 在 ItemTemplate 上设置属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21509374/