When binding and setting Visibility to Collapsed the item's empty space still remains. I have tested with many examples. Simple one is here
<ListBox x:Name="HorizontalListBox"> |
<ListBox.ItemsPanel> |
<ItemsPanelTemplate> |
<telerik:RadCarouselPanel/> |
</ItemsPanelTemplate> |
</ListBox.ItemsPanel> |
<ListBox.ItemTemplate> |
<DataTemplate> |
<TextBlock Text="{Binding Name}" Visibility="{Binding Visible}" /> |
</DataTemplate> |
</ListBox.ItemTemplate> |
</ListBox> |
<Button Height="23" Width="70" Content="lol" Click="Button_Click" /> |
public class Person : INotifyPropertyChanged |
{ |
private int age; |
private String name; |
public Person(String name, int age) |
{ |
this.name = name; |
this.age = age; |
} |
public int Age |
{ |
get { return this.age; } |
set { this.age = value; } |
} |
public String Name |
{ |
get { return this.name; } |
set { this.name = value; } |
} |
Visibility _visible = Visibility.Visible; |
public Visibility Visible |
{ |
get { return _visible; } |
set { _visible = value; OnPropertyChanged("Visible"); } |
} |
#region INotifyPropertyChanged Members |
public event PropertyChangedEventHandler PropertyChanged; |
protected void OnPropertyChanged(string pname) |
{ |
if (PropertyChanged != null) |
PropertyChanged(this, new PropertyChangedEventArgs(pname)); |
} |
#endregion |
} |
HorizontalListBox.ItemsSource = this.CreateItemSource(); // call from anywhere, like constructor |
ObservableCollection<Person> list = new ObservableCollection<Person>(); |
private ObservableCollection<Person> CreateItemSource() |
{ |
list.Add(new Person("George", 15)); |
list.Add(new Person("Rashko", 55)); |
list.Add(new Person("Britney", 60)); |
list.Add(new Person("Joe", 32)); |
list.Add(new Person("Vader", 34)); |
list.Add(new Person("Luke", 16)); |
list.Add(new Person("Jimmy", 105)); |
list.Add(new Person("Batman", 45)); |
list.Add(new Person("Butters", 9)); |
list.Add(new Person("Cartman", 9)); |
list.Add(new Person("Bender", 150)); |
return list; |
} |
private void Button_Click(object sender, RoutedEventArgs e) |
{ |
list[3].Visible = System.Windows.Visibility.Collapsed; |
} |
Now, when you click the button you can see the 4th item got invisible but still taking the space. However if you remove ListBox.ItemsPanel tagand then check again it will be collapsed as it should.
I have checked it with few examples and all are same, is there anyway to do that except removing the item from collection ?
Summary: Setting the 'Maximum' property to a value less than the 'Minimum' property causes any binding on the
'Maximum' property to break.
I have a control that has the following bindings:
<telerik:RadNumericUpDown
Minimum="0"
Maximum="{Binding Path=SnapshotCount, ElementName=GameDisplay, Mode=OneWay, Converter={StaticResource
SnapshotCountToMaxIndexConverter}}"
Value="{Binding Path=SnapshotIndex, ElementName=GameDisplay, Mode=TwoWay}"
/>
The problem is that when the SnapshotCountToMaxIndexConverter converter returns a value less than the minimum (in my particular case it was returning -1) then the following code is triggered to execute in RadRangeBase.cs:
private void CoerceMaximum()
{
if (this.Maximum < this.Minimum)
{
this.SetValue(MaximumProperty, this.Minimum);
}
This appears to break the binding because afterwardsI can see via breakpoints that the
OnMaximumPropertyChanged() method is no longer called.
The net effect of this is that the control becomes unusable because the only value that can then be entered into the field is the minimum value since the minimum and the maximum values are the same and the binding doesn't update what the maximum should be.
Interestly, I also have the exact same binding on a RadSlider() and the binding does not appear to break for that control.
NOTE: This problem is easy to avoid by ensuring that you never specify a maximum value that is less than the minimum.
PS: I love the controls by the way.
private void radGridView_MouseDoubleClick( object sender, MouseButtonEventArgs e ) { |
RadGridView radGrid = (RadGridView)sender; |
DataInfo actualRow = (DataInfo)radGrid.SelectedItem; |
actualRow.IsSelected = actualRow.IsSelected == false; |
} |
public
class
PlanningItem
{
public
string
ItemName {
get
;
set
; }
public
string
ItemFormat {
get
;
set
; }
public
double
ItemValue {
get
;
set
; }
}
<
telerik:RadGridView
AutoGenerateColumns
=
"False"
Name
=
"radGridView1"
ItemsSource
=
"{ Binding Path=PlanningItems }"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
UniqueName
=
"ItemName"
Header
=
"Item Name"
DataMemberBinding
=
"{ Binding Path=ItemName }"
IsReadOnly
=
"True"
/>
<
telerik:GridViewDataColumn
UniqueName
=
"ItemValue"
Header
=
"Item Value"
DataMemberBinding
=
"{ Binding Path=ItemValue}"
DataFormatString
=
"{ Binding ItemFormat }"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>