Hi Telerik:
I believe I have found a bug relating to how the RadRibbonTab handles things when its ItemsSource is set.
Please see the attached demo app.
Am I doing something wrong? If so, please advise.
<Window xmlns:local="clr-namespace:WpfApplication5" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="WpfApplication5.MainWindow" mc:Ignorable="d" Title="MainWindow" Height="659" Width="1131.575"> <Grid> <ListBox x:Name="List1" HorizontalAlignment="Left" Width="483" Height="73" VerticalAlignment="Top" Margin="30,77,0,0"/> <ListBox x:Name="List2" Margin="30,223,0,0" HorizontalAlignment="Left" Width="483" Height="84" VerticalAlignment="Top"/> <Button x:Name="btnBindList1" Content="Bind List 1" HorizontalAlignment="Left" Margin="513,77,0,0" VerticalAlignment="Top" Width="102" Click="btnBindList1_Click"/> <Button x:Name="btnBindList2" Content="Bind List 2" HorizontalAlignment="Left" Margin="518,223,0,0" VerticalAlignment="Top" Width="102" Click="btnBindList2_Click"/> <Label x:Name="label" Content="First - Click "Bind List 1". The items will bind. This is what I expect to happen." HorizontalAlignment="Left" Margin="30,43,0,0" VerticalAlignment="Top"/> <telerik:RadRibbonView x:Name="radRibbonView" VerticalAlignment="Top" Margin="30,385,108,0"> <telerik:RadRibbonTab Header="RibbonTab" x:Name="radRibbonTab"/> </telerik:RadRibbonView> <Button x:Name="btnBindRibbon" Content="Bind Ribbon to New Tab" HorizontalAlignment="Left" Margin="518,360,0,0" VerticalAlignment="Top" Width="158" Click="btnBindRibbon_Click"/> <Button x:Name="btnBindRibbon_Copy" Content="Bind Ribbon Again" HorizontalAlignment="Left" Margin="518,571,0,0" VerticalAlignment="Top" Width="193" Click="btnBindRibbon_Click"/> <Label x:Name="label_Copy" Content="Second - Click "Bind List 2". The list is bound and visual items jump to List2. This is what I expect to happen." HorizontalAlignment="Left" Margin="30,192,0,0" VerticalAlignment="Top"/> <Label x:Name="label_Copy1" Content="Third - Click "Bind Ribbon to New Tab". The list is bound and visual items jump into the ribbon. This is also what I expect to happen." HorizontalAlignment="Left" Margin="30,321,0,0" VerticalAlignment="Top" Width="799" Height="27"/> <Label x:Name="label_Copy2" Content="Last - Click "Bind Ribbon Again" (it calls the same code as above). When I do this, I get an error. I expect items to jump like they did the first time." HorizontalAlignment="Left" Margin="30,537,0,0" VerticalAlignment="Top" Width="799" Height="27"/> </Grid></Window>
using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;namespace WpfApplication5 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { System.Collections.ObjectModel.ObservableCollection<object> items; public MainWindow() { InitializeComponent(); items = new System.Collections.ObjectModel.ObservableCollection<object> { "a", "b", "c" }; items.Add(new Button() { Content = "Test Button" }); items.Add(new TextBox() { Text = "Test Textbox!" }); } private void Button_Click_1(object sender, RoutedEventArgs e) { Button button = sender as Button; string clickedString = button.DataContext as string; items.Remove(clickedString); } private void btnBindList1_Click(object sender, RoutedEventArgs e) { e.Handled = true; List1.ItemsSource = items; } private void btnBindList2_Click(object sender, RoutedEventArgs e) { e.Handled = true; List2.ItemsSource = items; } private void btnBindRibbon_Click(object sender, RoutedEventArgs e) { e.Handled = true; var Tab = new Telerik.Windows.Controls.RadRibbonTab() { Header = "New Tab" }; radRibbonView.Items.Add(Tab); radRibbonView.SelectedItem = Tab; Tab.ItemsSource = items; } }}