I have a "Busy" indicator that looks (and works) like so:
<Grid x:Key="BusyIndicator" Visibility="Hidden" Opacity="0">
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path = IsBusy}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource FadeInStoryboard}"/>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource FadeOutStoryboard}"/>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border Background="#90000000">
<Image Width="25" Height="25" RenderTransformOrigin="0.5, 0.5">
<Image.Source>
<BitmapImage UriSource="busy.png"/>
</Image.Source>
<Image.RenderTransform>
<RotateTransform Angle="0" />
</Image.RenderTransform>
<Image.Style>
<Style TargetType="{x:Type Image}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path = IsBusy}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource RotateStoryboard}"/>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Border>
</Grid>
As you can see, the indicator is a grid that's "Hidden" and "Invisible", when the "IsBusy" property changes, the grid fades in, and reveals a rotating "busy.png" image. When the "IsBusy" toggles off, the indicator fades to "Invisible" again, and disappears.
This all works.
What I can't seem to wrap my head around, is how do I make this control a resource in the App.xaml to be reused throughout the application? Because it's bound to the IsBusy property, I find myself having to cut and paste this monstrosity into every page that needs to use the indicator.
Is there a way to get the same effect, but with a reusable resource?
Edit:
So it really was as simple as stuffing it into a UserControl. Spent so much time trying to find the "WPF" solution, I forgot the basics. As ASh said, by simply adding a dependency property in the code-behind, using the control in a page now looks like this:
<local:BusyIndicator IsBusy="{Binding Path=IsBusy}"/>