首页 文章

我如何(以及在哪里)获得实际的ColumnDefinition Width =“*”

提问于
浏览
-1

我想要完成的简短版本 . 有一个带按钮的可滚动网格 . 按下按钮后,在现有行内容的右侧注入两个按钮,并将内容水平向左滚动,以便注入布局的第二个按钮的右边缘与屏幕的右边缘对齐 .

描述解决方案的更长版本尝试和遇到的问题:

我在ListView中有一行自定义控件(滚动视图中的网格) . 通常,网格与设备的宽度相同 .

节目的明星是<ColumnDefinition Width =“*”x:Name =“Star”/>

<Label Grid.Row="2" Grid.Column="3" Text="{Binding FacebookId}" x:Name="IDLabel"
                      Style="{StaticResource SmallLabelStyle}"
     HorizontalOptions="Fill"
     VerticalOptions="StartAndExpand" BackgroundColor="Red"
                     /> is assigned to that column later on in xaml

网格中用于删除和阻止按钮的最后两列最初为零宽度

<ColumnDefinition Width="0" x:Name="cdDelete"/>
<ColumnDefinition Width="0" x:Name="cdBlock"/>

并且因此,未显示(使标签的*列的大小正确,因为除了标签之外,网格中还有一个缩略图,一个按钮和间距列)

在这两个之前,有一个按钮列可以更改列宽,并在滚动视图中滚动展开的网格 .

因此,我需要一些方法将ColumnDefinition“*”的gridLength替换为我运行的设备的该列的实际宽度 .

this.cdBlock.Width = this.cdDelete.Width = Metrics.ThumbnailDiameter;
            if (starwidth <= 0)
            {
                starwidth = this.IDLabel.Width;
                       ^^^^^^^^^^^^^^^^^^^^^^^^^ problem is here: this returns the width the label fits into, not the actual width of the label highlighted (see red background above)
            }
            this.Star.Width = new GridLength(starwidth);

任何建议如何处理这个?

谢谢 .

1 回答

  • 0

    似乎ViewCell.ContextActions可用于利用平台表编辑功能

    这意味着除非有一种方法以编程方式显示上下文的按钮,否则显示删除/阻止按钮的按钮必须去

相关问题