Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions samples/features/Features.Avalonia/Bootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public Bootstrapper()

Initialize();

Task displayTask = DisplayRootViewFor<ShellViewModel>();
displayTask.Wait();
InitializeAsync();
}

private async void InitializeAsync()
{
await DisplayRootViewFor<ShellViewModel>();
}
protected override void Configure()
{
_container
Expand Down
14 changes: 3 additions & 11 deletions samples/features/Features.Avalonia/Views/ConductorView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</StackPanel>


<ListBox Name="Items" Grid.Row="1" Margin="40,0">
<ListBox Name="Items" Grid.Row="1" Margin="40,0" SelectedItem="{Binding ActiveItem, Mode=TwoWay}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
Expand All @@ -31,16 +31,8 @@
</ListBox.ItemTemplate>
</ListBox>

<Panel DataContext="{Binding ActiveItem}" Grid.Row="2" Margin="40">
<TextBlock Text="{Binding DisplayName}" FontSize="24" Foreground="Blue"/>
<ItemsControl ItemsSource="{Binding Messages}" Margin="30">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Panel>
<ContentControl cal:View.Model="{Binding ActiveItem}" Grid.Row="2" Margin="40">
</ContentControl>

</Grid>
</UserControl>
7 changes: 4 additions & 3 deletions samples/features/Features.Avalonia/Views/TabView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Features.CrossPlatform.Views.TabView">
<Grid>
<StackPanel>
<TextBlock Text="{Binding DisplayName}"></TextBlock>
<ItemsControl ItemsSource="{Binding Messages}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}"/>
<TextBlock Text="{Binding}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public ConductorViewModel()
Items.CollectionChanged += (s, e) => NotifyOfPropertyChange(() => CanCloseTab);
}

protected override async Task OnActivateAsync(CancellationToken cancellationToken)
{
// Optionally perform any logic before activation here
await base.OnActivateAsync(cancellationToken);
}
protected override async Task OnActivatedAsync(CancellationToken cancellationToken)
{
// Optionally perform any logic after activation here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public override Task<bool> CanCloseAsync(CancellationToken cancellationToken = d
return Task.FromResult(IsClosable);
}

[Obsolete("Use OnActivateAsync instead.")]
[Obsolete("Use OnActivatedAsync instead.")]
protected override async Task OnActivateAsync(CancellationToken cancellationToken)
{
if (deactivationDelay.HasValue)
Expand All @@ -115,7 +115,7 @@ protected override async Task OnActivateAsync(CancellationToken cancellationToke

protected override async Task OnActivatedAsync(CancellationToken cancellationToken)
{
//here

if (deactivationDelay.HasValue)
{
await Task.Delay(deactivationDelay.Value, cancellationToken).ConfigureAwait(false);
Expand Down
1 change: 0 additions & 1 deletion src/Caliburn.Micro.Platform/ActionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ protected override void OnAttached()
if (View.ExecuteOnLoad(AssociatedObject, ElementLoaded))
{
#if AVALONIA
//string eventName = "AttachedToLogicalTree";
string eventName = "Loaded";
var trigger = Interaction.GetBehaviors(AssociatedObject)
.OfType<EventTrigger>()
Expand Down
2 changes: 2 additions & 0 deletions src/Caliburn.Micro.Platform/ConventionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ static ConventionManager()
#endif
#if AVALONIA
AddElementConvention<UserControl>(UserControl.IsVisibleProperty, "DataContext", loadedEvent);
AddElementConvention<ListBox>(ListBox.ItemsSourceProperty, "DataContext", loadedEvent);
AddElementConvention<Panel>(Panel.DataContextProperty, "DataContext", loadedEvent);
#else
AddElementConvention<UserControl>(UserControl.VisibilityProperty, "DataContext", loadedEvent);
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/Caliburn.Micro.Platform/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ public static bool ExecuteOnLoad(FrameworkElement element, RoutedEventHandler ha
#if AVALONIA
public static void ExecuteOnUnload(FrameworkElement element, EventHandler handler)
{
EventHandler<LogicalTreeAttachmentEventArgs> unloaded = null;
EventHandler<RoutedEventArgs> unloaded = null;
unloaded = (s, e) =>
{
element.DetachedFromLogicalTree -= unloaded;
element.Unloaded -= unloaded;
handler(s, e);
};
element.DetachedFromLogicalTree += unloaded;
element.Unloaded += unloaded;
}
#else
public static void ExecuteOnUnload(FrameworkElement element, RoutedEventHandler handler)
Expand Down
Loading