Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:adorner_layer [2011/01/10 12:44] smayr |
swdev:dotnet:adorner_layer [2011/01/10 12:47] (current) smayr [Loading Adorner] |
||
---|---|---|---|
Line 155: | Line 155: | ||
Get Adorner Layer of a control, then add adorner: | Get Adorner Layer of a control, then add adorner: | ||
<code csharp> | <code csharp> | ||
+ | using System; | ||
+ | using System.Collections.Generic; | ||
+ | using System.Linq; | ||
+ | using System.Text; | ||
+ | using System.Windows; | ||
+ | using System.Windows.Controls; | ||
+ | using System.Windows.Data; | ||
+ | using System.Windows.Documents; | ||
+ | using System.Windows.Input; | ||
+ | using System.Windows.Media; | ||
+ | using System.Windows.Media.Imaging; | ||
+ | using System.Windows.Shapes; | ||
+ | namespace LoadingAdorner | ||
+ | { | ||
+ | /// < | ||
+ | /// Interaction logic for DemoPage.xaml | ||
+ | /// </ | ||
+ | public partial class DemoPage : Window | ||
+ | { | ||
+ | DemoPageController controller = new DemoPageController(); | ||
+ | |||
+ | public DemoPage() | ||
+ | { | ||
+ | DataContext = controller.Data; | ||
+ | InitializeComponent(); | ||
+ | |||
+ | AttachLoadingAdorner(); | ||
+ | } | ||
+ | |||
+ | private void AttachLoadingAdorner() | ||
+ | { | ||
+ | // Create " | ||
+ | LoadingAdorner loading = new LoadingAdorner(mainPane); | ||
+ | loading.FontSize = 15; | ||
+ | loading.OverlayedText = " | ||
+ | loading.Typeface = new Typeface(FontFamily, | ||
+ | FontWeights.Bold, | ||
+ | Binding bind = new Binding(" | ||
+ | bind.Source = controller; | ||
+ | bind.Converter = new VisibilityConverter(); | ||
+ | loading.SetBinding(LoadingAdorner.VisibilityProperty, | ||
+ | | ||
+ | // Get mainPane' | ||
+ | AdornerLayer.GetAdornerLayer(mainPane).Add(loading); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /// < | ||
+ | /// Converter that converts a bool to a Visibility status | ||
+ | /// </ | ||
+ | public class VisibilityConverter : IValueConverter | ||
+ | { | ||
+ | #region IValueConverter Members | ||
+ | |||
+ | public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
+ | { | ||
+ | return (bool)value ? Visibility.Visible : Visibility.Collapsed; | ||
+ | } | ||
+ | |||
+ | public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) | ||
+ | { | ||
+ | throw new NotImplementedException(); | ||
+ | } | ||
+ | |||
+ | #endregion | ||
+ | } | ||
+ | |||
+ | } | ||
</ | </ | ||