我正在尝试使用Visual Studio属性添加事件处理程序,但每次单击任何事件(例如我在XAML中选择一个按钮并尝试添加MyButton_Click
)时,我会弹出一个消息说“无法添加事件处理程序。”
用户控制
<UserControl x:Class=" TelerikWpfApp1.Control.ImageControl"
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"
mc:Ignorable="d"
d:DesignHeight="316" d:DesignWidth="391">
<Grid>
<!--<Grid.RowDefinitions>
<RowDefinition Height="30*" />
<RowDefinition Height="20" />
<RowDefinition Height="70*" />
</Grid.RowDefinitions>-->
<ScrollViewer Grid.Row="0">
<ItemsControl ItemsSource="{Binding Images}" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Border BorderThickness="3" Margin="10" x:Name="border" Background="White" CornerRadius="10" >
<Image Source="{Binding ImageUri}" Height="100" Width="100" />
<Border.Effect>
<DropShadowEffect />
</Border.Effect>
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="Black" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=border, Path=IsMouseOver}" Value="True">
<Setter Property="BorderBrush" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
<Border BorderBrush="Black" BorderThickness="3" Grid.Row="2" Visibility="Hidden" >
<Image Source="{Binding SelectedImage.ImageUri}" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
</Grid>