Grazie mi andro' a studiare la DataTemplate
nel frattempo posto quello che avevo gia' provato a fare ma senza successo
Questa e' la classe della ViewModel
namespace AntHR.ViewModel
{
public class AntSensorViewModel : ViewModelBase
{
#region Attribute
private IFrameNavigationService _navigationService;
private string _page1Text = "Channel";
private AntSensor antsens;
private ObservableCollection<AntSensorViewModel> antsensactive;
#endregion
#region Properties
public string Name => antsens.Name;
public int HBCount => antsens.HBCount;
public ObservableCollection<AntSensorViewModel> AntSensActive => antsensactive;
#endregion
#region Constructors
public AntSensorViewModel(AntSensor antsensor)
{
this.antsens = antsensor;
antsensactive = new ObservableCollection<AntSensorViewModel>();
}
#endregion
}
}
e questa e' la parte XAML
xmlns:ViewModel="clr-namespace:AntHR.ViewModel"
mc:Ignorable="d"
d:DesignHeight="150" d:DesignWidth="250"
Title="ChannelView" DataContext="{Binding Path=AntSensorViewModel, Source={StaticResource Locator}}">
<Viewbox>
<Grid>
<TreeView ItemsSource="{Binding AntSensorActive}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type ViewModel:AntSensorViewModel}" ItemsSource="{Binding Path=AntSensActive}">
<Border x:Name ="border" Background="Red" BorderBrush="Blue" BorderThickness="1" Margin="0,3">
<TextBlock Text="{Binding Name}" FontWeight="Bold"/>
</Border>
</HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
e questo e' quello che viene visualizzato: