1

UserControlにRadBusyIndi​​catorがあります。

<Grid>
    <!-- Other Content -->
    <t:RadBusyIndicator IsBusy="{Binding IsBusy}"></t:RadBusyIndicator>
</Grid>

デザインビューをクリックすると、BusyIndi​​catorに移動します。

Panel.ZIndexを負に設定して「その他のコンテンツ」を選択できますが、これによりRadBusyIndi​​catorが「その他のコンテンツ」の背後に表示されます。

私は次のようにZIndexのバインディングを使用してみました:

<t:RadBusyIndicator Panel.ZIndex="{Binding BusyZIndex}" IsBusy="{Binding IsBusy}"></t:RadBusyIndicator>

しかし、それは役に立ちません。

したがって、問題は次のとおりです。

すべての「その他のコンテンツ」の「トップ」にRadBusyIndi​​catorを配置し、(デザイナーで)クリックしてそのコントロールのxaml行に移動できるようにするにはどうすればよいですか?

4

1 に答える 1

1

BusyIndi​​catorは、コントロールの前に「上」にある必要があります。それはデザイナーのトップにもなります。

これを解決するためのより良い方法があるかもしれませんが、頭に浮かぶのは、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>

「TheBusyIndi​​cator」というキーを持つリソースとしてBusyIndi​​catorを追加しました。また、BusyIndi​​catorを含むグリッドにx:Name="LayoutRoot"を追加しました。もちろん、グリッドが実際にレイアウトルートコントロールでない場合は、グリッドに別の名前を付けることができます。

BusyIndi​​catorを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のみを使用し、作業するエディターがありません。したがって、この問題はしばらく発生していません。

于 2012-12-28T23:39:40.683 に答える