Silverlight 自定义启动屏幕中的进度条

发布于 2024-08-01 16:18:24 字数 599 浏览 3 评论 0原文

如何将 Silverlight ProgressBar 控件嵌入到自定义启动屏幕中? 我将以下内容放入松散的xaml中(为简洁起见,进行了简化):

<Grid xmlns="http://schemas.microsoft.com/client/2007"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <ProgressBar />
</Grid>

错误消息如下: 错误:Silverlight 应用程序中未处理的错误 代码:2007
类别:解析器错误
消息:未知元素:ProgressBar。
等等

ProgressBar 不是 http://schemas.microsoft.com/winfx/2006/xaml/presentation 命名空间?

How does one embed the Silverlight ProgressBar control in a a custom splash screen? I put the following into loose xaml (simplified for brevity):

<Grid xmlns="http://schemas.microsoft.com/client/2007"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
      <ProgressBar />
</Grid>

The error message is as follows:
Error: Unhandled Error in Silverlight Application
Code: 2007
Category: ParserError
Message: Unknown element: ProgressBar.
etc

Isn't the ProgressBar a standard control defined in the http://schemas.microsoft.com/winfx/2006/xaml/presentation namespace?

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

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

发布评论

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

评论(2

苏大泽ㄣ 2024-08-08 16:18:24

我假设是 SL2 或 SL3,因为进度条的存在 - 它已添加到 SL2 中。

/winfx/2006/xaml/presentation 名称空间未声明 - 但肯定在它所在的 SL2/3 中。 您已使用替代方案 http://schemas.microsoft.com/client/2007,此是 SL1.0 的遗留命名空间

给出的代码可以工作,但要重现,我必须将根元素作为用户控件,并且命名空间必须驻留在其中,否则用户控件标记本身将无法被识别。

<UserControl x:Class="myApp.scratchpad"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
       <ProgressBar />
    </Grid>
</UserControl>

在 SL3 中表现良好。

您能否发布更多页面、根元素、更新对 SL2/3 命名空间的引用,并说明正在使用哪个 SL 版本?

I'm assuming SL2 or SL3 since the presence of a progress bar - it got added in SL2.

The /winfx/2006/xaml/presentation name space isn't declared - but certainly in SL2/3 that is where it resides. You have used the alternative http://schemas.microsoft.com/client/2007, this is a legacy namespace for SL1.0

The code given will work, but to reproduce I have to have the root element as a user control and the namespaces have to reside in there, otherwise the usercontrol tag itself is not recognised.

<UserControl x:Class="myApp.scratchpad"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
       <ProgressBar />
    </Grid>
</UserControl>

Worked fine in SL3.

Can you post more of the page, root element, update the reference to the SL2/3 namespace and also say which verison of SL is being used?

九厘米的零° 2024-08-08 16:18:24

如果这是针对对象标记的 SplashScreenSource 属性,则 XAML 必须是 Silverlight 1+JavaScript(非托管 XAML),具体操作方法如下:(摘自 Silverlight SDK 此处)

<Canvas Background="Black" Width="302" Height="52">
    <Rectangle Canvas.Left="1" Canvas.Top="1" Width="300" Height="30" Fill="White"/>
    <Rectangle x:Name="progressBarFill" Canvas.Left="1" Canvas.Top="1" Height="30" Fill="Blue"/>
</Canvas>

然后使用 JS 函数来更新进度:

function onProgressChanged(sender, eventArgs)
{
    var slPlugin = sender.getHost();
    slPlugin.content.findName("progressBarFill").width = eventArgs.progress * 300;
}

If this is for the SplashScreenSource property of the object tag, then the XAML must be Silverlight 1+JavaScript (non-managed XAML) Here is how you would do that: (Taken from the Silverlight SDK here)

<Canvas Background="Black" Width="302" Height="52">
    <Rectangle Canvas.Left="1" Canvas.Top="1" Width="300" Height="30" Fill="White"/>
    <Rectangle x:Name="progressBarFill" Canvas.Left="1" Canvas.Top="1" Height="30" Fill="Blue"/>
</Canvas>

And then use a JS function to update the progress:

function onProgressChanged(sender, eventArgs)
{
    var slPlugin = sender.getHost();
    slPlugin.content.findName("progressBarFill").width = eventArgs.progress * 300;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文