无法找到并添加 SurfaceUserControl

发布于 2024-11-24 08:12:34 字数 1989 浏览 0 评论 0原文

我可以在 Surface 环境中非常轻松地创建 UserControl 并添加 TextBox。这是示例代码:

   <UserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:ScatterViewSizingSample"
         mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
         d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
    <TextBox HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top"/>
  </Grid>
   </UserControl>

我尝试添加 SurfaceUserControl 和 SurfaceTextBox,但找不到从菜单添加 SurfaceUserControl。我将 UserControl 更改为 s:SurfaceUserControl,将 Texbox 更改为 s:SurfaceTextbox,如下所示:

    <s:SurfaceUserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                 
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:s="http://schemas.microsoft.com/surface/2008"    
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:ScatterViewSizingSample"
         mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
         d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
    <s:SurfaceTextBox HorizontalAlignment="Left" Name="textBox1"/>
   </Grid>
 </s:SurfaceUserControl>

但系统显示错误“找不到类型 s:SurfaceWindows”。我添加了 Microsoft.Surface.Presentation 和 Microsoft.Surface.Presentation.Generic 程序集引用。但它仍然显示错误。

我该如何修复它?为什么系统不将 SurfaceUserControl 显示为 UserControl?

I can create UserControl and add TextBox very easily in Surface environment. Here is a sample code:

   <UserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:ScatterViewSizingSample"
         mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
         d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
    <TextBox HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top"/>
  </Grid>
   </UserControl>

I tried to add SurfaceUserControl and SurfaceTextBox, but I cannot find to add SurfaceUserControl from the menu. I changed UserControl to s:SurfaceUserControl and Texbox to s:SurfaceTextbox as follows:

    <s:SurfaceUserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"                 
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:s="http://schemas.microsoft.com/surface/2008"    
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:ScatterViewSizingSample"
         mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
         d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
    <s:SurfaceTextBox HorizontalAlignment="Left" Name="textBox1"/>
   </Grid>
 </s:SurfaceUserControl>

But the system shows error that 'the type s:SurfaceWindows does not found'. I added Microsoft.Surface.Presentation and Microsoft.Surface.Presentation.Generic assembly reference. But it still shows error.

How can I fix it? Why the system does not show SurfaceUserControl as UserControl?

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

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

发布评论

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

评论(2

属性 2024-12-01 08:12:34

使用 Surface 控件的应用程序需要使用 SurfaceWindow 作为其根视觉对象,以便执行所有自定义触摸处理。我怀疑,由于您正在尝试转换它,因此您可能仍在使用标准窗口,这会给您带来此错误。

An application using Surface controls needs to use SurfaceWindow as it's root visual in order to do all of the custom touch handling. I suspect that since you're trying to convert this you are probably still using a standard Window which is giving you this error.

哆兒滾 2024-12-01 08:12:34

如果您正在开发 2.0,SurfaceUserControl 将不再存在,根据 MSDN:

SurfaceUserControl 类已在 Surface 2.0 中删除。 Surface 1.0 SP1 中需要 SurfaceUserControl 类来为用户控件添加触摸支持。不过,.NET Framework 4 中的 UserControl 类已添加了触摸支持。要转换代码,请从“s:SurfaceUserControl”前面删除“s:Surface”,或使用 Surface Migration PowerToy。

< a href="http://msdn.microsoft.com/en-us/library/gg697151.aspx#User" rel="nofollow">来源

If you're developing for 2.0, SurfaceUserControl no longer exists, as per MSDN:

The SurfaceUserControl class has been removed in Surface 2.0. The SurfaceUserControl class was needed in Surface 1.0 SP1 to add touch support to user controls. However, touch support has been added to the UserControl class in .NET Framework 4. To convert your code, remove "s:Surface" from the front of "s:SurfaceUserControl", or use the Surface Migration PowerToy.

Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文