A combined tree and list UI is useful when the objects are categorized or structured into some other kind of tree. They
To create tools like the one above we can use the Visual Studio template Dynamix 6 - Tree and list objects UI
The template creates a class that inherits from Dynamix.Ui6.Dialogs.TreeAndListObjectsUi. It wraps this UI-class inside a DialogDescriptor.
public class MyTreeAndListDialog : DialogDescriptor
{
public MyTreeAndListDialog()
{
Title = "My tree and list tool";
OpenMode = DialogOpenMode.Window;
}
protected override PageDescriptor GetPage()
{
return PageDescriptor.Get<MyTreeAndListUi>();
}
private class MyTreeAndListUi : TreeAndListObjectsUi
{
}
}
Customizing the list
By default a grid view of the type TreeAndListObjectUi.ManageObjectsGridView is created. To customize columns or other functionality you can override the method CreateListView.
private class MyTreeAndListUi : TreeAndListObjectsUi {
// ...
protected override ListView CreateListView()
{
return new MyGridView();
}
private class MyGridView : ManageObjectsGridView {
public override IEnumerable<IGridViewColumn> GetColumns()
{
foreach( var baseCol in base.GetColumns() )
{
yield return baseCol;
}
yield return new DateTimeGridViewColumn<MySite.NewsItem>
{
HeaderText = "Date",
GetDate = n => n.Date
};
yield return new TextGridViewColumn<MySite.NewsItem> {
HeaderText = "Headline",
GetText = n => n.Headline
};
}
}
Customizing the toolbar and functionality
By default buttons are created for New, Edit/Properties, Delete, Clipboard (Copy,Cut,Paste) and Refresh.
To remove one or more of the standard buttons you can override HasAddNew, HasEdit, HasDelete, HasClipboard or HasUpdate to return false.
To customize which types of objects that can be created from the New-button override the GetObjectTypesForAdd method
protected override IEnumerable<TypeInformation> GetObjectTypesForAdd()
{
// You can check Tree.Selected to allow adding different types of object
// at different positions
var topCat = Tree.Selected as MySite.TopCategory;
if( topCat != null )
{
yield return new TypeInformation( typeof( MySite.Category ), true );
}
else {
yield return new TypeInformation( typeof( MySite.NewsItem ), true );
}
}