我在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>
感谢任何帮助,谢谢!
答案 0 :(得分:1)
它意味着您已声明了2个具有相同名称的控件,一个在标记中,另一个在后面的代码中。从后面的代码中删除声明。