This project is read-only.

Example of a treeview:


<TreeView x:Name="treeView1" Margin="0,0,1,0">
<TreeView.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Name="img" Width="14" Height="14" Stretch="Fill" Source="icon_rss.gif"/>
<TextBlock Text="{Binding}" Margin="5,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:Model.SCFarm}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Name="img" Width="16" Height="16" Stretch="Fill" Source="Images/farm.png"/>
<TextBlock Text="{Binding}" Margin="5,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:Model.SCServer}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Name="img" Width="16" Height="16" Stretch="Fill" Source="Images/server.png"/>
<TextBlock Text="{Binding}" Margin="5,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:Model.SCService}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Name="img" Width="16" Height="16" Stretch="Fill" Source="Images/service.png"/>
<TextBlock Text="{Binding}" Margin="5,0" VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TreeView.Resources>
</TreeView>


Example of a ListView for the property datasheet:

        <ListView Grid.Column="1" Name="listView1">
<ListView.Resources>
<DataTemplate x:Key="DataTemplateText">
<TextBox Text="{Binding Path=Value.Value, Mode=TwoWay}"/>
</DataTemplate>
<DataTemplate x:Key="DataTemplateCheckbox">
<CheckBox IsChecked="{Binding Path=Value.Value, Mode=TwoWay}"/>
</DataTemplate>
<DataTemplate x:Key="DataTemplateCombobox">
<ComboBox SelectedValue="{Binding Path=Value.Value, Mode=TwoWay}" ItemsSource="{Binding Value.Choices}" />
</DataTemplate>
<local:PropertyValueSelector x:Key="PropertyValueSelector"/>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Width="150" Header="Name" DisplayMemberBinding="{Binding Name}" />
<GridViewColumn Width="150" Header="Value" CellTemplateSelector="{DynamicResource PropertyValueSelector}" />
</GridView>
</ListView.View>
</ListView>

Adding horizontal gridlines to the listview grid:

        <ListView x:Name="listView1" Margin="3,0,0,0" Grid.Column="1" ItemsSource="{Binding}">
....
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    <Setter Property="BorderThickness" Value="0,0,0,1" />
                    <Setter Property="BorderBrush" Value="Gray" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Width="150" Header="Name" DisplayMemberBinding="{Binding Name}" />
                    <GridViewColumn Width="150" Header="Value" CellTemplateSelector="{DynamicResource PropertyValueSelector}" />
                </GridView>
            </ListView.View>
        </ListView>


Last edited Nov 30, 2010 at 8:29 PM by nsergiu, version 5

Comments

No comments yet.