This is a migrated thread and some comments may be shown as answers.

Trying out buttons in Telerik

1 Answer 69 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Anders T
Top achievements
Rank 1
Anders T asked on 16 Apr 2013, 12:01 PM
i cant seem to find a whole lot of info about how it works, are there beginner guides to the telerik wpf?
I downloaded 30days trial demo, but it just shows gui? The gui needs to be connected to my code behind, and this connection is what i cant find.
One thing i wanted to try was to make a button unEnabled after you press it, should be easy? I've tried a couple of things and none seems to work, please tell me what im doing wrong!
<Views:CustomViewBase.RibbonInformation>
    <entities:RibbonInformation Header="Operation">
        <entities:RibbonInformation.RibbonGroups>
            <telerik:RadRibbonGroup  x:Name="UIRibbonToolbar"  Header="Controls">
                 
                <telerik:RadRibbonButton Text="Back"
                                         Size="Large"
                                         LargeImage="/Images/Back.bmp"
                                         Click="RadRibbonButton_Click_Back"
                                         Name="RadRibbonButton_Back"
                                         IsEnabled="True"/>
                <telerik:RadRibbonButton Text="Play"
                                         Size="Large"
                                         LargeImage="/Images/Play.bmp"
                                         Click="RadRibbonButton_Click_Play"
                                         Name="RadRibbonButton_Play"
                                         IsEnabled="True"/>
                <telerik:RadRibbonButton Text="Stop"
                                         Size="Large"
                                         LargeImage="/Images/Stop.bmp"
                                         Click="RadRibbonButton_Click_Stop"
                                         Name="RadRibbonButton_Stop"
                                         IsEnabled="True"/>
                 
            </telerik:RadRibbonGroup>
        </entities:RibbonInformation.RibbonGroups>
    </entities:RibbonInformation>
</Views:CustomViewBase.RibbonInformation>
XAML
private void RadRibbonButton_Click_Stop(object sender, RoutedEventArgs e)
{
    this.IsEnabled = false;
    MessageBox.Show("Stop Button Pressed");
}
private void RadRibbonButton_Click_Play(object sender, RoutedEventArgs e)
{
    this.IsEnabled = false;
    MessageBox.Show("Play Button Pressed");
}
private void RadRibbonButton_Click_Back(object sender, RoutedEventArgs e)
{
    this.IsEnabled = false;
    MessageBox.Show("Back Button Pressed");
}
C#

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavel R. Pavlov
Telerik team
answered on 18 Apr 2013, 02:43 PM
Hi Anders,

As far as I understand you have RadRibbonView control and you want to disable one of its buttons when you click on them. If so your approach is correct. However, I noticed that in your Click event handler you set the IsEnabled property of the wrong element. Basically (in a simple scenario) if you say this the framework understands the MainWindow. In your case you need to cast the sender object to a RadRibbonButton and after that you can set its IsEnabled property to False. You can implement this approach like this:

private void RadRibbonButton_Click_Stop(object sender, RoutedEventArgs e)
{
    (sender as RadRibbonButton).IsEnabled = false;
    MessageBox.Show("Stop Button Pressed");
}
Let us know if you have any other questions.

Kind regards,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Buttons
Asked by
Anders T
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Share this question
or