I need an editable list on WPF that will save and edit XML, which element should I choose? DATAGRID? Design requirements scrolling, color scheme for even and odd entries, in the absence of data another blank template, help determine, also ask for links to the download manual and edit xml.
1 answer
Which element you choose depends on what you want to get in the end. WPF makes it easy to customize the look, so the answer to this question will be any. Including the proposed DataGrid .
To make the answer more understandable, let's look at a few examples of how you can display your data with various controls. Naturally, the list will be far from complete, but you can make a start from this. I took the data set from your previous question (although there are problems with the encoding)
1. ListView
If you need to display the properties of your object as a table, but without the ability to edit directly in it, then this control, in my opinion, will be a good choice.
Markup example:
<ListView AlternationCount="2" ItemsSource="{Binding Data}"> <ListView.Resources> <AlternationConverter x:Key="altconvBackground"> <SolidColorBrush Color="Orange" /> <SolidColorBrush Color="LightGray" /> </AlternationConverter> </ListView.Resources> <ListView.View> <GridView> <GridViewColumn Width="30" DisplayMemberBinding="{Binding ID}" Header="ID" /> <GridViewColumn Width="200" DisplayMemberBinding="{Binding FirstName}" Header="Имя" /> <GridViewColumn Width="200" DisplayMemberBinding="{Binding Last}" Header="Фамилия" /> <GridViewColumn Width="50" DisplayMemberBinding="{Binding Age}" Header="Возраст" /> <GridViewColumn Width="50" DisplayMemberBinding="{Binding Gender}" Header="Пол" /> <GridViewColumn Width="70" Header="Удалить"> <GridViewColumn.CellTemplate> <DataTemplate> <Button HorizontalAlignment="Stretch" Content="X" Padding="3" /> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> <ListView.ItemContainerStyle> <Style TargetType="{x:Type ListViewItem}"> <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Path=(ItemsControl.AlternationIndex), Converter={StaticResource altconvBackground}}" /> <Setter Property="HorizontalContentAlignment" Value="Center" /> </Style> </ListView.ItemContainerStyle> </ListView> Pay attention to the AlternationCount property, which shows how many styles you want to use.
Display
Of course, true / false doesn’t look good at all, but you can easily set up a display using a converter. And I did not want to inflate the answer with more details.
Given that you need to edit the data, it will be convenient to bring this functionality directly under our table.

ListBox. - user227049wpfis flexible enough to implement all of the above without any problems - user227049