0

Error CS0103 The name 'Status' does not exist in the current context

What is the correct syntax in order to make the controller be available in the .cs file?

<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>
barbsan
  • 3,418
  • 11
  • 21
  • 28
James Ellis
  • 31
  • 1
  • 5

1 Answers1

0

I suggested that you'd better use Binding to control the IsActive property value of ProgressRing. Then you do not need to get the control instance in code-behind.

<ProgressRing x:Name="Status" Foreground="Green" IsActive="{Binding xxx}" />
Xie Steven
  • 8,544
  • 1
  • 9
  • 23
  • https://stackoverflow.com/questions/16375375/how-do-i-access-a-control-inside-a-xaml-datatemplate what's the proper way of getting the parentContainer for the row? var pRing = FindControl(dataGrid, "Status"); pRing.IsActive = false; – James Ellis Feb 21 '19 at 14:26
  • @JamesEllis Have you checked my reply? I suggested you to use Binding. Why did you still want to get the control in DataTemplate? It's not a best practice. – Xie Steven Feb 25 '19 at 02:25
  • So if you bind the progress ring what would the best approach be to mimic time delay so that the progress status is shown? – James Ellis Feb 25 '19 at 19:01
  • @JamesEllis Did you mean that your data is loaded so fast that your progress only shows a short time? The users hardly see ProgressRing, right? – Xie Steven Feb 26 '19 at 02:47
  • See [Code Sample](https://github.com/Scnck/POC_Basket) trying to determine best appoarch. I want to copy/delete rows within DataGrid while showing a progressRing and mimic time delay. I want the logic to follow best practice. Thank you – James Ellis Feb 26 '19 at 20:15
  • You used `await Task.Delay(randomNumber);` to mimic time delay to make the ProgressRing show a little time. Then, the user can see it and know someone item has been copied/deleted. Not bad. You could use it. But I don't think you need to deliberately simulate a time-consuming operation to display the ProgressRing control. I think what users want is to save as much time as possible. You don't have to sacrifice the user experience in order to display the ProgressRing control. – Xie Steven Feb 27 '19 at 09:46
  • If you just want to let the users know someone item has been copied/deleted successfully. You could show a [InAppNotification](https://learn.microsoft.com/en-us/windows/communitytoolkit/controls/inappnotification) when the operation is finished. – Xie Steven Feb 27 '19 at 09:48
  • This project is just a proof of concept, I'm more looking at the proper way of handling blinding/DataGrid what is the correct way of handling the progressRing start/finish so that I can have multiple copy/deletes running and the progress indicator would be handled correctly? – James Ellis Feb 27 '19 at 13:48
  • Currently "seleted.isLoading = true;" doesn't automatically refresh the DataGrid. – James Ellis Feb 28 '19 at 01:08
  • @JamesEllis There's no relationship between 'seleted.isLoading = true' and 'automatically refresh the DataGrid'. If you want to refresh the DataGrid, you need to refresh the ItemsSource. – Xie Steven Feb 28 '19 at 02:16