【问题标题】:issue in watermark textbox水印文本框中的问题
【发布时间】:2021-06-11 14:18:09
【问题描述】:

我是 wpf 的新手。我下载了 wpf 工具包,然后将它的 dll 文件添加到我的项目文件中。然后尝试了一些代码来创建水印文本框,但显示错误(XML 命名空间中不存在标签“WatermarkTextBox”)。

<Window 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  
x:Class="TRAINING.WaterMark"
x:Name="Window"
Title="WaterMark"
Width="640" Height="480">
<extToolkit:WatermarkTextBox>
        <extToolkit:WatermarkTextBox.Watermark>
            <StackPanel Orientation="Horizontal">
                <Image Source="Contact16.png" Stretch="None" />
                <TextBlock Text="Enter First Name" Margin="4,0,0,0" />
            </StackPanel>
        </extToolkit:WatermarkTextBox.Watermark>
    </extToolkit:WatermarkTextBox>  
</Window>

请帮忙。

【问题讨论】:

  • 您遇到的错误是什么?你在哪里引用 extToolkit 作为命名空间?
  • 我确定您已经这样做了,但是您检查了工具包上的参考资料吗?是否添加到您的项目中(右键单击,“添加引用”,或者更好地使用 Nuget)?

标签: c# wpf


【解决方案1】:

我以前没有使用过 wpf 工具包,但我很确定你已经使用 xctk 添加了命名空间,那么你应该在 xaml 中使用它 - 即 xctk:WatermarkTextBox 而不是 extToolkit:WatermarkTextbox

【讨论】:

    【解决方案2】:
    <Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"  
    x:Class="TRAINING.WaterMark"
    x:Name="Window"
    Title="WaterMark"
    Width="640" Height="480">
    <extToolkit:WatermarkTextBox>
            <extToolkit:WatermarkTextBox.Watermark>
                <StackPanel Orientation="Horizontal">
                    <Image Source="Contact16.png" Stretch="None" />
                    <TextBlock Text="Enter First Name" Margin="4,0,0,0" />
                </StackPanel>
            </extToolkit:WatermarkTextBox.Watermark>
        </extToolkit:WatermarkTextBox>  
    </Window>
    

    我猜你错过了那个 extToolkit 的引用,所以我添加了。希望对你有帮助

    【讨论】:

    • 这是行不通的。它也显示错误(XML命名空间中不存在标签'WatermarkTextBox')
    【解决方案3】:

    我出现这个问题的原因是 xceed ($) 与 dotnetprojects(免费)NuGet 包之间的混淆。

    所以一旦我卸载了 xceed,一切正常,错误也得到解决。

    【讨论】:

      猜你喜欢
      • 2014-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      相关资源
      最近更新 更多