Skip to content

Instantly share code, notes, and snippets.

@Bert-Proesmans
Created November 19, 2019 13:21
Show Gist options
  • Save Bert-Proesmans/ac7bb7311deca94839758b0b67b8190c to your computer and use it in GitHub Desktop.
Save Bert-Proesmans/ac7bb7311deca94839758b0b67b8190c to your computer and use it in GitHub Desktop.
Loading custom control
public class LoadingControl : UserControl
{
public static readonly DependencyProperty TaskHandlerProperty =
DependencyProperty.Register(nameof(TaskHandler), typeof(ITaskHandler), typeof(Loading),
new FrameworkPropertyMetadata(""));
public Loading()
{
InitializeComponent();
}
public ITaskHandler TaskHandler
{
get => (ITaskHandler)GetValue(TaskHandlerProperty);
set => SetValue(TaskHandlerProperty, value);
}
private static void OnHandlerChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
// TODO; Register listeners on the new TaskHandler dependencyproperty
// bool ITaskHandler.IsBusy will indicate if there is work performing in the background or not
}
private void OnTaskBusyChanged(object sender, PropertyChangedEventArgs e) {
// TODO; Switch the visibility of the current control:
// Visible on IsBusy == true
// Collapsed on IsBusy == false
}
}
<usercontrol>
<Border height="50pt">
<TextBlock Text="Loading.."/>
</border>
</usercontrol>
<usercontrol>
<grid>
[CONTENTS]
<loadingcontrol verticalalignment="bottom" TaskHandler="{Binding}"/>
</grid>
</usercontrol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment