SelectionBoxTemplate not updated

8 posts, 0 answers
  1. Rudis
    Rudis avatar
    30 posts
    Member since:
    Feb 2010

    Posted 22 Jun 2010 Link to this post

    Hello,
    I´m want to be able to multiselect in a ComboBox and therefore uses a  SelectionBoxTemplate. But there is a strange problem.
    <totally:RadComboBox  Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="3" Name="StatusarComboBox" HorizontalAlignment="Stretch" 
                          ItemsSource="{Binding ARStatusar}" IsTextSearchEnabled="False" MaxWidth="190" > 
                        <totally:RadComboBox.ItemTemplate> 
                            <DataTemplate> 
                                <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" Content="{Binding Text}" /> 
                            </DataTemplate> 
                        </totally:RadComboBox.ItemTemplate> 
     
                        <totally:RadComboBox.SelectionBoxTemplate> 
                            <DataTemplate> 
                                <TextBlock Text="{Binding Owner.CheckedItems, Converter= StaticResource ValueConverter}, UpdateSourceTrigger=PropertyChanged}"/> 
                            </DataTemplate> 
                        </totally:RadComboBox.SelectionBoxTemplate> 
                    </totally:RadComboBox> 

    The comma separated text returned from the ValueConverter that shows the selected items does not always update. Only mouse clicks sometime updates the text. And after it starts working, it seems to always work. It also seems to always work when leaving the ComboBox using enter.

    I´ve used this example:
    http://www.telerik.com/community/forums/silverlight/combobox/multiselect-option-in-combo-box.aspx

    Any ideas to this strange behavour? I want to be able to only use mouse clicks.

    Best regards,
    Anna
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 25 Jun 2010 Link to this post

    Hello Anna,

    Thank you for contacting us.

    Could you please give us some more information how to reproduce this behaviour. Sending us a sample project or a short video will be really helpful. In that way we will be able to track down the source of the problem.

    Looking forward to your reply.

    Best wishes,
    Konstantina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Matthew
    Matthew avatar
    33 posts
    Member since:
    Aug 2008

    Posted 24 Nov 2010 Link to this post

    Bump.... Has anyone resolved this? I'm having the issue, too.
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 25 Nov 2010 Link to this post

    Hi Matthew,

    Since we couldn't reproduce it at our side, we still don't have any solution for it. If someone could send us a sample application and steps to reproduce it would be very helpful.

    Looking forward to your reply.

    Sincerely yours,
    Konstantina
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  6. Rudis
    Rudis avatar
    30 posts
    Member since:
    Feb 2010

    Posted 25 Nov 2010 Link to this post

    This solved my problem, the ItemContainerStyle:

    <totally:RadComboBox  Grid.Column="7" Grid.Row="0" TabIndex="15"
             ItemsSource="{Binding SkvStatusar}" MaxWidth="190" >
             <totally:RadComboBox.ItemContainerStyle>
                  <Style TargetType="totally:RadComboBoxItem">
                      <Setter Property="IsSelected" Value="{Binding IsChecked}" />
                  </Style>
             </totally:RadComboBox.ItemContainerStyle>
     
              <totally:RadComboBox.ItemTemplate>
                   <DataTemplate>
                       <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}" Content="{Binding Text}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
                    </DataTemplate>
               </totally:RadComboBox.ItemTemplate>
     
               <totally:RadComboBox.SelectionBoxTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Owner.CheckedItems, Converter={StaticResource ValueConverter}, UpdateSourceTrigger=PropertyChanged}"/>
                    </DataTemplate>
               </totally:RadComboBox.SelectionBoxTemplate>
           </totally:RadComboBox>
  7. Rudis
    Rudis avatar
    30 posts
    Member since:
    Feb 2010

    Posted 07 Dec 2010 Link to this post

    Another issue with this checkable combobox. When you click on the "frame" of an item, all previously checkad items will be unchecked and only that item is chosen.

    Is there a way around this?

    Best regards,
    Anna
  8. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 10 Dec 2010 Link to this post

    Hello Anna,

    As I mentioned before, since this feature is not supported out-of-the-box, there might be some issues.
    However, I tried to reproduce it, but to no avail. If you could send us a short video in which we can observe
    the problem, we might be able to provide you with a possible solution. Also, is this is happening with the
    ItemContainerStyle or without? If you share with us, also, which version of the controls you are using, it would be very helpful.

    Looking forward to your reply.

    Greetings,
    Konstantina
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  9. Matthew
    Matthew avatar
    33 posts
    Member since:
    Aug 2008

    Posted 13 Dec 2010 Link to this post

    Hi Anna,

    I don't know if your current problem is related to your work around, but we solved the original problem (selected items do not always update) in a different manner. I'll share our approach, and maybe it will shed light on your current problem?

    It appeared that the selected items were not getting updated because, upon initial use of the RCB, the SelectedItem of the RCB is not set (null). Since it uses the SelectedItem to determine the value for the selected items text (i.e. SelectedItem.Owner.SelectedItems, converted to CSV using the converter), the SelectedItem of the RCB needs to be set.

    My solution my be convoluted (open for suggestions), but what I did was:

    1. Added an event to the DataItemsCollection so that it would get fired when the items were changed: 
    public class DataItemCollection : ObservableCollection<DataItem>
    {
        private EventHandler SelectedItemsChangedEvent;
     
        public event EventHandler SelectedItemsChanged
        {
            add { SelectedItemsChangedEvent += value; }
            remove { SelectedItemsChangedEvent -= value; }
        }
     
        protected virtual void OnSelectedItemsChanged(EventArgs e)
        {
            if (SelectedItemsChangedEvent != null)
                SelectedItemsChangedEvent(this, e);
        }
     
        private void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Selected")
            {
                DataItem item = sender as DataItem;
                if (item.Selected)
                {
                    if (this.selectedItems == null || !this.SelectedItems.Contains(item))
                    {
                        this.SelectedItems.Add(item);
                        this.OnPropertyChanged(new PropertyChangedEventArgs("SelectedItems"));
                        OnSelectedItemsChanged(new EventArgs());
                    }
                }
                else
                {
                    if (this.selectedItems != null && this.SelectedItems.Contains(item))
                    {
                        this.SelectedItems.Remove(item);
                        this.OnPropertyChanged(new PropertyChangedEventArgs("SelectedItems"));
                        OnSelectedItemsChanged(new EventArgs());
                    }
                }
            }
        }
    }


    2. Added a listener to the object when we initialized it, and when it was fired, made sure an RCB item was selected (Editor is a reference to underlying RCB):
    DataItems = new DataItemCollection();
    DataItems.SelectedItemsChanged += (s, e) =>
    {
        if (Editor.SelectedItem == null && Editor.Items.Count > 0)
            Editor.SelectedIndex = 0;
    };



Back to Top
UI for WPF is Visual Studio 2017 Ready