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

RibbonButton stays highlighted if it is dragged

4 Answers 94 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 15 Feb 2012, 10:39 AM
Hi,

I am currently developing a small flowchart tool. Therefore I use a menu consisting of several RibbonButtons. The user can drag a button from the menu onto a canvas and drop it there. The problem is now, that the dragged button is still highlighted if the left mouse-button is released on the canvas to drop it there. The result is a menu with a lot of highlighted buttons (view attached picture).

Is there a way to release the selection of the button manually? Or does anyone know another solution to this problem.

Thanks for your help,
Andreas

4 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 20 Feb 2012, 10:21 AM
Hi Andreas,

The issue is caused by the fact that the buttons remain in their mouse over visual state. But you can manually set their state back to normal on DragCompleted:

public void OnDragCompleted(object sender, Telerik.Windows.DragDrop.DragDropCompletedEventArgs args)
{
    VisualStateManager.GoToState((args.Data as RadRibbonButton), "Normal", false);
}


However, as you said you need to create a flow chart, it would be easier to take advantage of the new Telerik Diagraming Framework. You can examine its demo here - if you open the Backstage menu of the RibbonView you'll find a couple of flow chart samples that can get you started. You can also examine the online documentation of the framework here.

All the best,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Andreas
Top achievements
Rank 1
answered on 20 Feb 2012, 03:07 PM
Hi,

setting the visual state did only partly solve the problem. The dragged button is deselected now, but the RadRibbonGroup to which the button belongs is still highlighted. Setting the visual state of the group didn't help.

Here the essential parts of the XAML:
<DataTemplate x:Name="ButtonTemplate">
   <telerikRibbon:RadRibbonButton HorizontalContentAlignment="Stretch" Loaded="MenuItem_Loaded" Command="{Binding ButtonClickCommand}">
     <StackPanel Orientation="Vertical" Width="70">
     <Image Source="{Binding ImgSource}" Margin="0,0,4,0" Height="18" Width="18" HorizontalAlignment="Center"></Image>
     <TextBlock Text="{Binding Text}" HorizontalAlignment="Center"></TextBlock>
     </StackPanel>
   </telerikRibbon:RadRibbonButton>
</DataTemplate>
......
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" Margin="3,1,0,0" >
   <telerikRibbon:RadRibbonGroup x:Name="GroupEdit" Header="{Binding TXT020, Source={StaticResource DesignerWindowResources}}" ItemsSource="{Binding EditItems}" ItemTemplate="{StaticResource ButtonTemplate}"/>
   <telerikRibbon:RadRibbonGroup x:Name="GroupItems" Header="{Binding TXT021, Source={StaticResource DesignerWindowResources}}" ItemsSource="{Binding MenuItems}" ItemTemplate="{StaticResource ButtonTemplate}" />
</StackPanel>

Thanks for your help,
Andreas
0
Accepted
Tina Stancheva
Telerik team
answered on 23 Feb 2012, 10:23 AM
Hi Andreas,

The issue with the RibbonGroup is caused again by the fact that during the drag process the control doesn't receive a MouseLeave event to notify it that the mouse over state has finished. However using the VisualStateManager can help again. However as an uncollapsed RadRibbonGroup is represented by the GroupChrome control, you need to change its state:
public void OnDragCompleted(object sender, Telerik.Windows.DragDrop.DragDropCompletedEventArgs args)
{
    VisualStateManager.GoToState((args.Data as RadRibbonButton), "Normal", false);
    GroupChrome groupChromeElement = (args.OriginalSource as RadRibbonButton).ParentOfType<GroupChrome>();
    VisualStateManager.GoToState(groupChromeElement, "Normal", false);
 
}

Give this a try and let me know if it helps.

Regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Andreas
Top achievements
Rank 1
answered on 23 Feb 2012, 04:23 PM
Hi Tina,

thanks, it works.

Thank you also for the hint to Telerik Diagraming Framework. I will have a look at it.

Kind regards,
Andreas
Tags
RibbonView and RibbonWindow
Asked by
Andreas
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or