Question


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>
Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top