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

Radgallery Initial Selection

5 Answers 51 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
laxman
Top achievements
Rank 1
laxman asked on 24 Jan 2011, 08:54 PM
Hi,

I am trying to add RadGallery to DropDownButton. And I am unable to set the initial Selected value.
here is the code snippet. But if dropdown is already opened once than I am able to set the selected value.

public void LoadValues()
{
            _DropDownButton = new RadRibbonDropDownButton()
            {
                Text = StringResource.Size,
                Size = ButtonSize.Large,
                LargeImage = new BitmapImage()
            };

            _RadGallery = new RadGallery()
            {
                VerticalContentAlignment = System.Windows.VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Left,
                ViewportHeight = 340,
                ViewportWidth = 150            
            };

 _RadGallery.ItemsSource = MyDataSource
 
 _DropDownButton.DropDownContent = RadGallery;

//set intial values.
 _RadGallery.selectedItem=InitialValue;

}

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 27 Jan 2011, 11:09 AM
Hello laxman,

Due to design specifications, RadRibbonButton.DropDownContent is generated  when the dropdown button is clicked. You can use the Loaded event of the Gallery to set its SelectedIndex or SelectedItem.
Feel free to ask if you need further assistance.

Best wishes,
Petar Mladenov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
laxman
Top achievements
Rank 1
answered on 27 Jan 2011, 10:11 PM
Hi,

The problem is that now initially I have to click DropDownButton 2 times to open it.
Once its opened than it works fine.

Thanks,

Laxman
0
Petar Mladenov
Telerik team
answered on 28 Jan 2011, 02:08 PM
Hello laxman,

Could you please examine the attached project and let me know if I am missing something? You only have to click once on the DropDownButton, then the gallery Loads and the SelectedIndex is set. You can modify the project or send me another sample showing the issue you have come up with so that we can investigate in depth. 

Kind regards,
Petar Mladenov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
laxman
Top achievements
Rank 1
answered on 28 Jan 2011, 10:24 PM
Hi,

I am not adding RadGalleryItem to radGallery.
Here is my code snippet


private RadGallery _Gallery3;

private void AddNewLayout()
{
AddNewLayouData();
            var group = new RadRibbonGroup();
            group.Name = "new group";
            group.Width = 400;
            radRibbonTab.Items.Add(group);

            var button3 = new RadRibbonDropDownButton() { Text = "FinalTest", Size = ButtonSize.Large };
            group.Items.Add(button3);

            var stackPanel3 = new StackPanel();
            _Gallery3 = new RadGallery() { ViewportHeight = 200, ViewportWidth = 160 };
            _Gallery3.ItemsSource = _List;
            stackPanel3.Children.Add(_Gallery3);

            button3.DropDownContent = stackPanel3;

            _Gallery3.Loaded +=new RoutedEventHandler(_Gallery3_Loaded);

}

        private void _Gallery3_Loaded(object sender, RoutedEventArgs e)
        {
            _Gallery3.Loaded -= _Gallery3_Loaded;
            _Gallery3.SelectedItem = "T Test";
        }

        private List<string> _List;
        private IList<string> _List1;
        private void AddNewLayouData()
        {
            IList<string> list = new List<string>();
            list.Add("Potrait1");
            list.Add("LandScape");
            list.Add("A test");
            list.Add("T Test");
            list.Add("P Test");
            list.Add("C Test");
            _List = new List<string>(list);
            _List.Sort();

            _List1 = new List<string>();
            _List1.Add("Potrait1");
            _List1.Add("LandScape");
            _List1.Add("A test");
            _List1.Add("T Test");
            _List1.Add("P Test");
            _List1.Add("C Test");

      }

0
Petar Mladenov
Telerik team
answered on 02 Feb 2011, 07:14 PM
Hello laxman,

This appears to be a bug in the RadGallery since it inherits from Telerik.Windows.Controls.ListBox which is obsolete control. We logged this in our PITS (RibbonBar: Setting the SelectingItem of the RadGallery from code behind is problematic) where you will be soon able  to vote for. We also updated your telerik points accordingly.

Greetings,
Petar Mladenov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Buttons
Asked by
laxman
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
laxman
Top achievements
Rank 1
Share this question
or