【问题标题】:The type 'x' already contains a definition for 'y'类型“x”已经包含“y”的定义
【发布时间】:2013-06-16 09:07:47
【问题描述】:

我在代码中收到以下错误,我在属性选项卡中更改了 2 个按钮的名称。

Error   1   The type 'x100.MainWindow' already contains a definition for 'startBtn
Error   2   The type 'x100.MainWindow' already contains a definition for 'listBtn'

这是我的 XAML 文件

<Window x:Class="x100.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="696" Width="538">
<Grid>
    <Button x:Name="startBtn" Content="Start" HorizontalAlignment="Left" Height="55" Margin="10,601,0,0" VerticalAlignment="Top" Width="101" Click="startBtn"/>
    <Button x:Name="listBtn" Content="List (.exe)" HorizontalAlignment="Left" Height="55" Margin="126,601,0,0" VerticalAlignment="Top" Width="105"/>
    <TextBox x:Name="txtBoxShow" HorizontalAlignment="Left" Height="596" Margin="10,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="510"/>
    <Button Content="List (.jpg)" HorizontalAlignment="Left" Height="55" Margin="247,601,0,0" VerticalAlignment="Top" Width="105"/>

</Grid>               
</Window>

感谢任何帮助,谢谢!

【问题讨论】:

    标签: xaml button types definition


    【解决方案1】:

    这意味着您已经声明了 2 个具有相同名称的控件,一个在标记中,一个在后面的代码中。从后面的代码中删除声明。

    【讨论】:

    • @ScorpioBlue 你的 .xaml.cs 页面
    • 当我使用我的按钮名称和函数名称时,我遇到了同样的错误。
    猜你喜欢
    • 1970-01-01
    • 2018-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    • 1970-01-01
    相关资源
    最近更新 更多