Change Visibility of RadBadge

1 Answer 66 Views
Badge
Bernd
Top achievements
Rank 1
Bernd asked on 22 Nov 2024, 03:10 PM

Hello,

i'm using a RadButton with a RadBadge to open an dialog with new  messages.

Now i'm wondering how to  hide the RadBadge when there are no new messages...

In my viewmodel i have a property (bool) that indicates, if the badge should be visible or not...

 

Here's the XAML - its part of a datatemplate for a RadWindow:

<telerik:RadButton x:Name="manButton"  Grid.Column="7" Margin="10,6" Command="{Binding ShowManCommand}" Focusable="False">
    <telerik:RadButton.Content>
        <Image Source="{iconPacks:MaterialImage CommentTextMultipleOutline, Brush=White}" Margin="4" />
    </telerik:RadButton.Content>
    <telerik:RadBadge.Badge>
        <telerik:RadBadge BadgeType="ContentOnly"  AnchorPosition="1,1" Position="1.1,0.4" 
                          Geometry="{telerik:Geometry Type=Oval}" Background="Red" 
                          FontSize="12" Height="16" Width="28"
                          Content="{Binding ManMessageCount}" 
                          Visibility="{Binding IsManBadgeVisible, Converter={converter:BoolToVisibilityConverter}}"/>
    </telerik:RadBadge.Badge>
</telerik:RadButton>

 

Is there a possibility to hide/collapse the RadBadge?  It seems that the visibility property isn't working...

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 27 Nov 2024, 12:51 PM

Hello Bernd,

I tested the specified behavior and binding the Visibility property to a property from the view model correctly shows/hides the RadBadge element. However, the Binding for the mentioned property should have its Mode property set to TwoWay (since it will be modified from the view model):

<telerik:RadBadge.Badge>
    <telerik:RadBadge BadgeType="ContentOnly" 
                      AnchorPosition="1,1"
                      Position="1.1,0.4" 
                      Geometry="{telerik:Geometry Type=Oval}" 
                      Background="Red" 
                      FontSize="12"  
                      Height="16" 
                      Width="28"
                      Visibility="{Binding IsBadgeVisible, Mode=TwoWay, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</telerik:RadBadge.Badge>

With this being said, I attached a sample application for you to test.

Regards,
Stenly
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.

Bernd
Top achievements
Rank 1
commented on 28 Nov 2024, 07:21 AM

Hi Stenly,

sometimes the solution can be that simple...   ;-)

Thanks a lot!

 

Regards,

Bernd

Tags
Badge
Asked by
Bernd
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or