Button (In silverlight) does not have Click property
I need my silverlight button to call a specific method, but my button doesn't have any click property. The Intellisense shows "clickmode" but no "click"
I'm definitely using the System.Windows.Controls.Button control
Here's my code for the xaml file
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schema开发者_开发问答s.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Telerik_Windows_Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" x:Class="..."
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<Telerik_Windows_Controls:RadChart Name="radChart" Content="RadChart" Margin="78,47,0,0" d:LayoutOverrides="Width, Height"/>
</Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="75"/>
</UserControl>
A WPF button has an "OnClick" event, or a "Command" property. You may find this link useful: WPF Commanding Overview
Silverlight's Button
does have an event called Click
, defined in ButtonBase
, see the MSDN API documentation. So you might write XAML like:
<Button Content="Button" ... Click="My_Event_Handler"/>
However, have a look at Commanding as referenced by the other answer for the "nice" way to do things (Button's Command property).
精彩评论