【问题标题】:Can't use WrapPanel in SilverLight Application无法在 SilverLight 应用程序中使用 WrapPanel
【发布时间】:2014-09-17 12:52:53
【问题描述】:

我正在构建我的第一个 Silverlight 应用程序,并尝试在我的一个视图中使用 WrapPanel。但是我收到以下错误。

错误 1 ​​名称空间中不存在名称“WrapPanel” “http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit”。

我的代码:

xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
...
<toolkit:WrapPanel Height="657" Width="657" />

我需要安装一个包还是什么?如果有,怎么做?

【问题讨论】:

  • 你添加了对System.Windows.Controls.Toolkit的引用吗?

标签: c# xaml silverlight wrappanel


【解决方案1】:

请参考此链接::

WrapPanel

【讨论】:

    【解决方案2】:

    实际上 WrapPanel 控件不是 Silverlight 的一部分,而是 Silverlight Toolkit 的一部分。在使用 WrapPanel 控件之前,您必须下载 Silverlight Toolkit。之后,您需要添加对程序集的引用。您将从安装 Silverlight Toolkit 的文件夹中获得 Microsoft.Windows.Controls.dll 程序集。现在,您必须将 Microsoft.Windows.Controls 命名空间导入页面。在页面中键入 xmlns= 后,您将在 Intellisense 中看到 Microsoft.Windows.Controls 列表。

    <Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    x:Class="Demo.App" 
    xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
    xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls">
        <Application.Resources>
                <!-- Resources scoped at the Application level should be defined here. -->
                <ItemsPanelTemplate x:Key="ExamplePanal">
                                <controls:WrapPanel/>
                </ItemsPanelTemplate>
        </Application.Resources>
    

    上面的例子 "xmlns:controls="clr-namespace:Microsoft.Windows.Controls" 添加这个 dll 然后 WrapPanel 添加到 Intellisense。同时键入控件:intellisense 在列表中显示 WrapPanal。 请参阅下面的代码,我正在添加 ExamplePanal。

    <Control
    ItemsPanel="{StaticResource ExamplePanal}"
    ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
    

    我认为这可能对你有所帮助..

    谢谢

    乔姆·乔治

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多