Trying out buttons in Telerik

2 posts, 1 answers
  1. Anders T
    Anders T avatar
    1 posts
    Member since:
    Apr 2013

    Posted 16 Apr 2013 Link to this post

    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#
  2. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 18 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top