Hi there,
I am using the tree view control in my silverlight project. I use data binding for binding my model to the tree. This works perfect.
After adding some features to the tree I ran into two problems:
When I change a property on my Model, the tree does not get updated, even after my onproperty changed get called and also my converter is not called?(I need to hide the item when a specific property changes) (Answered)
How do I hide an Item in the tree? (I use Textbox + image as Item template)
Stack panel is hidden, but empty container remains in tree
DataTemplate:
<common:HierarchicalDataTemplate ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal" Visibility="{Binding IsAvailable, Converter={StaticResource ItemVisibleConverter} ,Mode=TwoWay}" >
<Image Source="{Binding Converter={StaticResource ImageConverter}}"/>
<controls:Label Name="myItem" Content="{Binding Description, Converter={StaticResource ItemConverter} ,Mode=TwoWay}" Foreground="Black"/>
</StackPanel>
</common:HierarchicalDataTemplate>
Converter: public object Convert(object value, Type targetType, object parameter, ystem.Globalization.CultureInfo culture) { return GetVisibility(value); }
private Visibility GetVisibility(object value)
{
bool IsVisible= (bool)value;
if (IsAvailableForDownload)
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
}
Model
public class MyModel: INotifyPropertyChanged
{
public bool IsAvailable
{
get
{
return _IsAvailableForDownload;
}
set
{
_IsAvailableForDownload = value;
onPropertyChanged(this, "IsAvailableForDownload");
}
}
//Code for on property changed event
}
Regards