xamarin.forms - Xamarin.Forms:将项目添加到代码中的特定网格行
问题描述
在我的 XAML 中,我有这个网格:
<Grid Grid.Row="12" Grid.Column="1" ColumnSpacing="0" >
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<!--Label-->
<RowDefinition Height="3*" ></RowDefinition>
<!--ProfilePic-->
<RowDefinition Height="*"></RowDefinition>
<!-- Btn change-->
</Grid.RowDefinitions>
<BoxView BackgroundColor="Purple" Grid.Row="1"></BoxView>
<ImageButton
Grid.Row="2"
x:Name="row_forpic_editProfile"
HorizontalOptions="Center"
VerticalOptions="Center"
/>
<Label
Grid.Row="0"
FontSize="16"
TextColor="#272727"
VerticalOptions="End"
Text="Proilfbild"
FontFamily="arial"
/>
<Button
Grid.Row="2"
x:Name="btn_changepic_editprofile"
Text="Ändern"
HorizontalOptions="Center"
VerticalOptions="Center"
/>
</Grid>
这是这样做的结果:
现在,我想从代码中将图像视图添加到紫色行(即 Grid.Row="1")中,因为我从互联网上下载了一张图片。
我现在如何将我的新图像 (ImageButton) 添加到这个确切的行中?(第 1 行)并让它保持其尺寸(只有图片必须填满容器)。
谢谢你:)
解决方案
将 a 添加View
到 aGrid
myGrid.Children.Add(view,col,row);
推荐阅读
- java - 将 ArrayList 从 Java Servlet 传递到 JSP 时遇到问题
- javascript - 如何从firebase数据库中获取用户uid并将其打印在表上
- php - Laravel 5.6: How to make App\sys_data::where($moreWhere)->paginate(10); work?
- javascript - 在 javascript 中使用 map 或 reduce 打印斐波那契数列
- selenium - 我们真的使用 TestNG 并行运行模式来执行 Web 测试吗?
- google-app-engine - deploy go api 不发送任何响应
- javascript - javascript (ES6):为什么我们需要集合?
- bootstrap-4 - 使用按钮设置表单值 (Bootstrap/Bootstrap Studio)
- reactjs - 有条件地在 React 中围绕 div 渲染锚链接
- javascript - 无法访问 .beforeEach() 中的 Buefy 组件