在 Silverlight 4 中,如何向 BusyIndi​​cator 控件添加取消按钮?

发布于 2024-10-10 04:44:26 字数 134 浏览 1 评论 0原文

我相信您可以编辑 BusyIndi​​cator 的模板,但是,我没有表达式混合,而且我不熟悉这样做。有人有我可以开始使用的示例 XAML 吗?

我认为混合只是让它更容易完成,但我不确定如何从标准 VS.NET 开始。

I believe you can edit the template for the BusyIndicator, however, I do not have expression blend and I am not familiar with doing this. Does anyone have sample XAML that I could start with?

I presume blend just makes it easier to accomplish, but I am unsure how to begin with standard VS.NET.

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

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

发布评论

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

评论(2

じ违心 2024-10-17 04:44:26

无需使用 Expression Blend - 您只需为控件提供 BusyContentTemplate 即可。 Silverlight Toolkit 示例在此演示了这一点: http://www.silverlight .net/content/samples/sl4/toolkitcontrolsamples/run/default.html。复制并粘贴这些示例中的片段:

<controlsToolkit:BusyIndicator IsBusy="True" DisplayAfter="0">
    <controlsToolkit:BusyIndicator.BusyContentTemplate>
        <DataTemplate>
            <StackPanel Margin="4">
                <TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center"/>
                <StackPanel Margin="4">
                    <TextBlock Text="Downloading message 4/10..."/>
                    <ProgressBar Value="40" Height="15"/>
                </StackPanel>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0" Content="Pause" HorizontalAlignment="Right" Margin="0 0 2 0"/>
                    <Button Grid.Column="1" Content="Cancel" HorizontalAlignment="Left" Margin="2 0 0 0"/>
                </Grid>
            </StackPanel>
        </DataTemplate>
    </controlsToolkit:BusyIndicator.BusyContentTemplate>
</controlsToolkit:BusyIndicator>

希望这有帮助......

克里斯

There's no need to use Expression Blend - you can simply provide the control with a BusyContentTemplate. The Silverlight Toolkit examples demonstrate this here: http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html. Copying and pasting a snippet from those examples:

<controlsToolkit:BusyIndicator IsBusy="True" DisplayAfter="0">
    <controlsToolkit:BusyIndicator.BusyContentTemplate>
        <DataTemplate>
            <StackPanel Margin="4">
                <TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center"/>
                <StackPanel Margin="4">
                    <TextBlock Text="Downloading message 4/10..."/>
                    <ProgressBar Value="40" Height="15"/>
                </StackPanel>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Button Grid.Column="0" Content="Pause" HorizontalAlignment="Right" Margin="0 0 2 0"/>
                    <Button Grid.Column="1" Content="Cancel" HorizontalAlignment="Left" Margin="2 0 0 0"/>
                </Grid>
            </StackPanel>
        </DataTemplate>
    </controlsToolkit:BusyIndicator.BusyContentTemplate>
</controlsToolkit:BusyIndicator>

Hope this helps...

Chris

彩扇题诗 2024-10-17 04:44:26

此 xaml 解决了我在使用 Toolkit 源中的标准示例 XAML(由 Chris 发布)时遇到的两个问题。我还简化了 XAML,仅添加一个取消按钮。

  1. 数据绑定(请参见此处:http://forums.silverlight.net/forums/p /163280/368692.aspx )
  2. 隐藏默认进度条,b/c 一旦您使用数据模板,您应该使用自己的进度条,这样您就可以控制定位

注意:我正在使用 Caliburn Micro 进行 MVVM ,如果您不使用 MVVM,您可能只使用“取消”按钮的普通单击事件处理程序。

代码示例:

<Controls:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding}">
    <Controls:BusyIndicator.BusyContentTemplate>
        <DataTemplate>
            <StackPanel Margin="4">
                <TextBlock Text="{Binding BusyContent}" FontWeight="Bold" HorizontalAlignment="Center" Margin="2"/>
                <ProgressBar IsIndeterminate="True" Height="15" Margin="2"/>
                <Button cal:Message.Attach="CancelBusyIndicator()" Content="Cancel"  HorizontalAlignment="Right" Margin="2 2 2 2"/>
            </StackPanel>
        </DataTemplate>
    </Controls:BusyIndicator.BusyContentTemplate>
    <Controls:BusyIndicator.ProgressBarStyle>
        <Style TargetType="ProgressBar">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
    </Controls:BusyIndicator.ProgressBarStyle>

This xaml addresses 2 issues that I had problems with by using the standard sample XAML (posted by Chris) from the Toolkit sources. I have also simplified the XAML to just add a Cancel button .

  1. Data binding ( see here: http://forums.silverlight.net/forums/p/163280/368692.aspx )
  2. Hiding the default progress bar, b/c once you use data template you should use your own progress bar, so you can control positioning

NOTE: I am using Caliburn Micro for MVVM, and if you're not using MVVM you'll probably just use a normal click event handler for the Cancel button.

Code sample:

<Controls:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="{Binding}">
    <Controls:BusyIndicator.BusyContentTemplate>
        <DataTemplate>
            <StackPanel Margin="4">
                <TextBlock Text="{Binding BusyContent}" FontWeight="Bold" HorizontalAlignment="Center" Margin="2"/>
                <ProgressBar IsIndeterminate="True" Height="15" Margin="2"/>
                <Button cal:Message.Attach="CancelBusyIndicator()" Content="Cancel"  HorizontalAlignment="Right" Margin="2 2 2 2"/>
            </StackPanel>
        </DataTemplate>
    </Controls:BusyIndicator.BusyContentTemplate>
    <Controls:BusyIndicator.ProgressBarStyle>
        <Style TargetType="ProgressBar">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
    </Controls:BusyIndicator.ProgressBarStyle>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文