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

SelectionBoxTemplate not updated

7 Answers 202 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rudis
Top achievements
Rank 1
Rudis asked on 22 Jun 2010, 03:01 PM
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

7 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 25 Jun 2010, 11:26 AM
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
0
Matthew
Top achievements
Rank 1
answered on 24 Nov 2010, 09:21 PM
Bump.... Has anyone resolved this? I'm having the issue, too.
0
Konstantina
Telerik team
answered on 25 Nov 2010, 12:15 PM
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
0
Rudis
Top achievements
Rank 1
answered on 25 Nov 2010, 02:33 PM
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>
0
Rudis
Top achievements
Rank 1
answered on 07 Dec 2010, 09:19 PM
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
0
Konstantina
Telerik team
answered on 10 Dec 2010, 11:15 AM
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
0
Matthew
Top achievements
Rank 1
answered on 13 Dec 2010, 04:51 PM
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;
};



Tags
ComboBox
Asked by
Rudis
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Matthew
Top achievements
Rank 1
Rudis
Top achievements
Rank 1
Share this question
or