BusyIndicatorは、コントロールの前に「上」にある必要があります。それはデザイナーのトップにもなります。
これを解決するためのより良い方法があるかもしれませんが、頭に浮かぶのは、BusyPanelをUserControlのリソースにしてから、グリッドコントロールのOnApplyTemplateまたはLoadedbycodeに追加することです。
これがUserControlのXAMLです。
<UserControl x:Class="WpfApplication2.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:t="REFERENCE.TO.THE.RAD.ASSEMBLY"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<t:RadBusyIndicator x:Key="TheBusyIndicator" IsBusy="{Binding IsBusy}">
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Button Content="Some content to the button"
Height="25"
Width="200"/>
</Grid>
</UserControl>
「TheBusyIndicator」というキーを持つリソースとしてBusyIndicatorを追加しました。また、BusyIndicatorを含むグリッドにx:Name="LayoutRoot"を追加しました。もちろん、グリッドが実際にレイアウトルートコントロールでない場合は、グリッドに別の名前を付けることができます。
BusyIndicatorをChildrenコレクションに最後に追加すると、マークアップコードによって追加された他のすべてのコントロールの前に表示されます。
これがコードです
UserControlのコンストラクター:
public UserControl1()
{
this.Loaded += new RoutedEventHandler(UserControl1_Loaded);
}
実行コード:
private void UserControl1_Loaded(object sender, RoutedEventArgs e)
{
this.LayoutRoot.Children.Add(this.Resources["TheBusyIndicator"] as RadBusyIndicator);
}
私はもうUserControlsを使用することはなく、XAMLが「Generic.xaml」に移動するCustomControlsのみを使用し、作業するエディターがありません。したがって、この問題はしばらく発生していません。