2012-12-28 57 views
1

RadBusyIndi​​cator总是选择我有我的用户一个RadBusyIndi​​cator像这样:当设计师点击

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

每当我在设计视图中单击它去BusyIndi​​cator控件。

我可以设置Panel.ZIndex为负,选择“其他内容”,但这样会导致RadBusyIndi​​cator是背后的“其他内容”

我使用的Z-索引像这样绑定尝试:

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

但它没有帮助。

所以,问题是:

我怎么有RadBusyIndi​​cator上“顶级”所有的“其他内容”,但仍可以点击(在设计),去了的XAML行控制?

+0

更好的方法是使用'd:IsHidden =“true”' – jbarker

回答

1

BusyIndi​​cator需要“在上面”才能在控件之前。这使得它在设计师中也处于顶峰。

可能有更好的方法来解决这个问题,但是想到的是在UserControl上使BusyPanel成为资源,然后将其添加到网格控件OnApplyTemplate或Loaded by代码中。

这里是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> 

我已经加入了BusyIndi​​cator控件与重点 “TheBusyIndi​​cator” 资源。 我还为网格添加了x:Name =“LayoutRoot”,它将包含BusyIndi​​cator。 如果Grid实际上不是布局根控件,那么当然可以使用其他名称。

通过最后将BusyIndi​​cator添加到Children集合中,它将出现在由标记代码添加的所有其他控件的前面。

下面是代码

用户控件的构造函数:

public UserControl1() 
{ 
    this.Loaded += new RoutedEventHandler(UserControl1_Loaded); 
} 

的execting代码:

private void UserControl1_Loaded(object sender, RoutedEventArgs e) 
{ 
    this.LayoutRoot.Children.Add(this.Resources["TheBusyIndicator"] as RadBusyIndicator); 
} 

我从来没有使用用户控件了,只有CustomControls在XAML去“通用.xaml“,我没有编辑工作。所以我暂时还没有看到这个问题。

+0

像冠军一样工作! 谢谢:) – jbarker

+0

非常好:-)很高兴我能帮忙! –