Replies: 3 comments 5 replies
-
Sure, something like this, I'm still exploring though. public class MyDocumentDock : DocumentDock
{
public static readonly DirectProperty<MyDocumentDock, IAvaloniaList<Document>?> DocumentsProperty =
AvaloniaProperty.RegisterDirect<MyDocumentDock, IAvaloniaList<Document>?>(nameof(Documents), o => o.Documents, (o, v) => o.Documents = v);
IAvaloniaList<Document>? documents;
[DataMember(IsRequired = false, EmitDefaultValue = true)]
[JsonPropertyName("Documents")]
public IAvaloniaList<Document>? Documents
{
get => documents;
set => SetAndRaise(DocumentsProperty, ref documents, value);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
if (change.Property == DocumentsProperty)
{
if (change.OldValue is IAvaloniaList<Document> old)
{
old.CollectionChanged -= Documents_CollectionChanged;
}
if (change.NewValue is IAvaloniaList<Document> newValue)
{
newValue.CollectionChanged += Documents_CollectionChanged;
}
}
base.OnPropertyChanged(change);
}
void Documents_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
if (DocumentTemplate is null)
{
return;
}
var document = e.NewItems?.OfType<Document>().SingleOrDefault();
if (document is not null)
{
document.Content = DocumentTemplate.Content;
Factory?.AddDockable(this, document);
Factory?.SetActiveDockable(document);
Factory?.SetFocusedDockable(this, document);
}
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
var document = e.OldItems?.OfType<Document>().SingleOrDefault();
if (document is not null)
{
Owner!.Factory!.CloseDockable(document);
}
}
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
also for another project i wnat to try to put Bepu physics in tit .. its more important now for me than monogame.. the demos use OpenTk ..i dont care if its directx or opengl.. https://github.com/SamboyCoding/OpenTKAvalonia it not been maintain a while.. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to use DocumentTemplate like the DockXamlSample,but it looks like not work.
my VM code like this:
DocumentViewModel like this
Beta Was this translation helpful? Give feedback.
All reactions