Since_2008
Since_2008

Reputation: 2341

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://schemas.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>

Upvotes: 0

Views: 270

Answers (2)

Nicholas W
Nicholas W

Reputation: 2241

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).

Upvotes: 0

Tom Studee
Tom Studee

Reputation: 10452

A WPF button has an "OnClick" event, or a "Command" property. You may find this link useful: WPF Commanding Overview

Upvotes: 1

Related Questions