Unplanned
Last Updated: 01 Mar 2024 12:17 by ADMIN
KL
Created on: 01 Mar 2024 12:10
Category: Toolbar
Type: Bug Report
0
Toolbar: IsEnabled does not work through binding on items level

When setting IsEnabled through binding, it does not work on items level, it works on toolbar level. Still the Isvisible property works on items level. 

<telerik:RadToolbar x:Name="toolbar" >
    <telerik:ToggleButtonToolbarItem Text="ToggleButton" IsEnabled="{Binding IsActive, Mode=TwoWay}">
        <telerik:ToggleButtonToolbarItem.ImageSource>
            <FontImageSource Glyph="{x:Static telerik:TelerikFont.IconBold}"
                        FontFamily="{x:Static telerik:TelerikFont.Name}"
                        Size="16" />
        </telerik:ToggleButtonToolbarItem.ImageSource>
    </telerik:ToggleButtonToolbarItem>
</telerik:RadToolbar>

 

 

1 comment
ADMIN
Didi
Posted on: 01 Mar 2024 12:17

Solution:

1) Set the IsEnabled on RadToolbar level.

 

2) Use triggers and toolbar item  style:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
             xmlns:local="clr-namespace:MauiApp3"
             x:Class="MauiApp3.MainPage">
    <ContentPage.Resources>
        <ResourceDictionary>
            <Style TargetType="telerik:ToggleButtonToolbarItemView">
                <Style.Triggers>
                    <DataTrigger TargetType="telerik:ToggleButtonToolbarItemView" Binding="{Binding IsToggled, Source={x:Reference switch}}" Value="False">
                        <Setter Property="IsEnabled" Value="False" />
                        <Setter Property="BackgroundColor" Value="LightBlue"/>
                         Multiple Setter elements are allowed 
                    </DataTrigger>
                    <DataTrigger TargetType="telerik:ToggleButtonToolbarItemView" Binding="{Binding IsToggled, Source={x:Reference switch}}" Value="True">
                        <Setter Property="IsEnabled" Value="True" />
                        <Setter Property="BackgroundColor" Value="LightCoral"/>
                         Multiple Setter elements are allowed 
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <VerticalStackLayout>
        <Switch x:Name="switch" IsToggled="False"/>
        <telerik:RadToolbar x:Name="toolbar" >
            <telerik:ToggleButtonToolbarItem Text="ToggleButton" >
                <telerik:ToggleButtonToolbarItem.ImageSource>
                    <FontImageSource Glyph="{x:Static telerik:TelerikFont.IconBold}"
                                FontFamily="{x:Static telerik:TelerikFont.Name}"
                                Size="16" />
                </telerik:ToggleButtonToolbarItem.ImageSource>
            </telerik:ToggleButtonToolbarItem>
        </telerik:RadToolbar>
    </VerticalStackLayout>
</ContentPage>

 

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.