Radgallery Initial Selection

6 posts, 0 answers
  1. laxman
    laxman avatar
    9 posts
    Member since:
    Jan 2011

    Posted 24 Jan 2011 Link to this post

    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;

    }

  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 27 Jan 2011 Link to this post

    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>>
  3. DevCraft banner
  4. laxman
    laxman avatar
    9 posts
    Member since:
    Jan 2011

    Posted 27 Jan 2011 Link to this post

    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
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 28 Jan 2011 Link to this post

    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>>
  6. laxman
    laxman avatar
    9 posts
    Member since:
    Jan 2011

    Posted 28 Jan 2011 Link to this post

    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");

          }

  7. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 02 Feb 2011 Link to this post

    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>>
Back to Top
DevCraft banner