我在哪里放置 busyindicator 来包裹整个页面,因此在活动完成之前不会启用任何控件

发布于 2024-10-13 05:37:30 字数 2795 浏览 7 评论 0原文


我正在使用 MVVM Light 在 Silverlight 4 中创建一个应用程序。

目前我有一个包含许多控件的页面,即。 StackPanels、列表框、TexBlocks 和按钮。我在页面上有一个绑定到视图模型的忙碌指示器。当单击按钮从数据库检索数据时,忙碌指示器会显示并在呼叫完成后消失。

这一切都按其应有的方式进行。

我想要发生的是整个页面都包含在 busyindicator 中,以便页面变暗并且在事件完成之前没有任何效果。我读到您只需将控件包装在 Busyindicator 中即可。 无论我将指标的开口放在何处,我都会看到蓝线,显示“属性内容已设置多次。” 我已经发布了下面的代码,任何人都可以解释在哪里放置指标代码。

        <Grid.RowDefinitions>
            <RowDefinition Height ="0" />
            <RowDefinition Height ="30" />
            <RowDefinition Height ="60" />
            <RowDefinition Height ="Auto" />
            <RowDefinition Height ="40" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="1" Grid.Column="0" Text="Header" Width="353" Margin="0 0 0 0" Height="30" />

        <StackPanel Grid.Row="2"  VerticalAlignment="Center" Orientation="Horizontal" >

            <Button Grid.Row="2" Grid.Column="0" Content="GetData" Height="35" Width="130" HorizontalAlignment="Left" Margin="0,0,0,0"  Command="{Binding GetData}"></Button>
            <!--  <toolkit:BusyIndicator Width="150" Height="50" IsBusy="{Binding IsBusy}" BusyContent="Searching ..."  /> -->

        </StackPanel>

        <ListBox x:Name="MyListBox" Grid.Row="3">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="400"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>

                        <Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Content="Delete" VerticalAlignment="Center" 
                            Command="{Binding Delete}"></Button>
                    </Grid>

                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <TextBlock Grid.Row="4" Margin="5,10,0,0" Text="{BindingMessage}"></TextBlock>

</Grid>

I am creating an app in Silverlight 4 with MVVM Light.

At present I have a page with many controls ie. StackPanels, Listbox, TexBlocks and Buttons. I have a busyindicator on the page that is bound to a viewmodel. When a button is clicked to say retrieve data from the database the busyindicator displays and vanishes when the call is completed.

This all works as it should.

What I want to happen is that the whole page is wrapped in the busyindicator so that the page dims and nothing works until the event is completed. I have read that you just wrap the control inside the Busyindicator.
No matter where I place the opening of the indicator I get blue lines showing 'The property Content is set more than once.'
I have posted the code below, could anyone explain where to put the indicator code.

        <Grid.RowDefinitions>
            <RowDefinition Height ="0" />
            <RowDefinition Height ="30" />
            <RowDefinition Height ="60" />
            <RowDefinition Height ="Auto" />
            <RowDefinition Height ="40" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="1" Grid.Column="0" Text="Header" Width="353" Margin="0 0 0 0" Height="30" />

        <StackPanel Grid.Row="2"  VerticalAlignment="Center" Orientation="Horizontal" >

            <Button Grid.Row="2" Grid.Column="0" Content="GetData" Height="35" Width="130" HorizontalAlignment="Left" Margin="0,0,0,0"  Command="{Binding GetData}"></Button>
            <!--  <toolkit:BusyIndicator Width="150" Height="50" IsBusy="{Binding IsBusy}" BusyContent="Searching ..."  /> -->

        </StackPanel>

        <ListBox x:Name="MyListBox" Grid.Row="3">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="400"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>

                        <Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Content="Delete" VerticalAlignment="Center" 
                            Command="{Binding Delete}"></Button>
                    </Grid>

                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <TextBlock Grid.Row="4" Margin="5,10,0,0" Text="{BindingMessage}"></TextBlock>

</Grid>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

许一世地老天荒 2024-10-20 05:37:30

您需要将所有内容放入用户控件中,如下所示:

<toolkit:BusyIndicator Width="150" Height="50" IsBusy="{Binding IsBusy}" BusyContent="Searching ...">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height ="0" />
            <RowDefinition Height ="30" />
            <RowDefinition Height ="60" />
            <RowDefinition Height ="Auto" />
            <RowDefinition Height ="40" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="1" Grid.Column="0" Text="Header" Width="353" Margin="0 0 0 0" Height="30" />
        <StackPanel Grid.Row="2"  VerticalAlignment="Center" Orientation="Horizontal" >
            <Button Grid.Row="2" Grid.Column="0" Content="GetData" Height="35" Width="130" HorizontalAlignment="Left" Margin="0,0,0,0"  Command="{Binding GetData}"></Button>

        </StackPanel>
        <ListBox x:Name="MyListBox" Grid.Row="3">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="400"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>
                        <Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Content="Delete" VerticalAlignment="Center"                              Command="{Binding Delete}"></Button>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Grid.Row="4" Margin="5,10,0,0" Text="{BindingMessage}"></TextBlock>
    </Grid>
</toolkit:BusyIndicator>

You need to put all the content inside the user control as shown below:

<toolkit:BusyIndicator Width="150" Height="50" IsBusy="{Binding IsBusy}" BusyContent="Searching ...">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height ="0" />
            <RowDefinition Height ="30" />
            <RowDefinition Height ="60" />
            <RowDefinition Height ="Auto" />
            <RowDefinition Height ="40" />
        </Grid.RowDefinitions>
        <TextBlock Grid.Row="1" Grid.Column="0" Text="Header" Width="353" Margin="0 0 0 0" Height="30" />
        <StackPanel Grid.Row="2"  VerticalAlignment="Center" Orientation="Horizontal" >
            <Button Grid.Row="2" Grid.Column="0" Content="GetData" Height="35" Width="130" HorizontalAlignment="Left" Margin="0,0,0,0"  Command="{Binding GetData}"></Button>

        </StackPanel>
        <ListBox x:Name="MyListBox" Grid.Row="3">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="400"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                            <ColumnDefinition Width="10"></ColumnDefinition>
                            <ColumnDefinition Width="70"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Text="{Binding Name}"></TextBlock>
                        <Button Grid.Row="0" Grid.RowSpan="2" Grid.Column="3" Content="Delete" VerticalAlignment="Center"                              Command="{Binding Delete}"></Button>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Grid.Row="4" Margin="5,10,0,0" Text="{BindingMessage}"></TextBlock>
    </Grid>
</toolkit:BusyIndicator>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文