【问题标题】:UWP: DataGrid + ProgressRingUWP:数据网格 + ProgressRing
【发布时间】:2019-07-13 06:11:48
【问题描述】:

错误 CS0103 当前上下文中不存在名称“状态”

为了使控制器在 .cs 文件中可用,正确的语法是什么?

<controls:DataGridTemplateColumn Header="OrderId">
    <controls:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ContextFlyout>
                    <MenuFlyout>
                        <MenuFlyoutItem Text="Copy" Icon="Copy" Click="MenuFlyoutItem_Copy" />
                        <MenuFlyoutSeparator />
                        <MenuFlyoutItem Text="Delete" Icon="Delete" Click="MenuFlyoutItem_Delete" />
                    </MenuFlyout>
                </Grid.ContextFlyout>
                <TextBlock Text="{Binding OrderId}" />
                <ProgressRing x:Name="Status" Foreground="Green" IsActive="True" />
            </Grid>
        </DataTemplate>
    </controls:DataGridTemplateColumn.CellTemplate>
</controls:DataGridTemplateColumn>

【问题讨论】:

    标签: uwp datagrid xamarin.uwp windows-community-toolkit


    【解决方案1】:

    我建议你最好使用Binding来控制ProgressRing的IsActive属性值。那么你就不需要在代码隐藏中获取控件实例了。

    <ProgressRing x:Name="Status" Foreground="Green" IsActive="{Binding xxx}" />
    

    【讨论】:

    • stackoverflow.com/questions/16375375/… 获取该行的 parentContainer 的正确方法是什么? var pRing = FindControl(dataGrid, "Status"); pRing.IsActive = false;
    • @JamesEllis 你检查我的回复了吗?我建议你使用绑定。为什么还要在 DataTemplate 中获得控制权?这不是最佳做法。
    • 那么,如果你绑定进度环,模拟时间延迟以显示进度状态的最佳方法是什么?
    • @JamesEllis 您的意思是您的数据加载速度如此之快以至于您的进度只显示很短的时间吗?用户几乎看不到 ProgressRing,对吧?
    • 请参阅Code Sample 尝试确定最佳方案。我想复制/删除 DataGrid 中的行,同时显示progressRing 并模拟时间延迟。我希望逻辑遵循最佳实践。谢谢
    猜你喜欢
    • 2020-01-28
    • 1970-01-01
    • 2018-06-08
    • 1970-01-01
    • 2020-12-16
    • 1970-01-01
    • 2020-08-02
    • 2020-12-15
    • 1970-01-01
    相关资源
    最近更新 更多