【发布时间】:2020-01-27 14:53:57
【问题描述】:
我正在尝试制作一个可以在手机和平板电脑中不同的 xaml。我有这样的事情:
<OnIdiom x:TypeArguments="View">
<OnIdiom.Phone>
<ContentView VerticalOptions="CenterAndExpand">
...
<LineEntry x:Name="User" Style="{StaticResource Style1}"/>
...
</ContentView>
</OnIdiom.Phone>
<OnIdiom.Tablet>
<ContentView VerticalOptions="End">
...
<LineEntry x:Name="User" Style="{StaticResource Style2}"/>
...
</ContentView>
</OnIdiom.Tablet>
</OnIdiom>
但不能在代码隐藏中使用相同的 id 名称。我能怎么做?我不想为每个平台使用 2 个变量(例如 userPhone 和 userTablet)。有另一种方法来实现吗?谢谢!
【问题讨论】:
标签: xaml xamarin.forms