0

我在这里有一个用户控件,我想覆盖我当前的区域。除非它没有出现。

这是我的 SpatialMode.xaml 代码:

<UserControl x:Class="FilteringModule.View.SpatialFilterMode"
         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" 

        MouseDown="UserControl_MouseDown"
        MouseUp="UserControl_MouseUp"
        MouseMove="UserControl_MouseMove">

<Canvas x:Name="SpatialCanvas" Background="Wheat">
    <Border 
            x:Name="dragSelectionBorder"
            BorderBrush="Blue"
            BorderThickness="1"
            Background="LightBlue"
            CornerRadius="1"
            Opacity="0.5"
            />
</Canvas>
</UserControl>

我称之为:

    public void ShowSpatialFilterMode()
    {
        Console.WriteLine("SHOWING SPATIAL FILTER MODE?");
        _spatialFilterMode = new SpatialFilterMode();
        _spatialFilterMode.Visibility = Visibility.Visible;
    }

它写入控制台,所以我知道它正确地击中它,除了它没有显示?

任何帮助将不胜感激。

谢谢!

4

2 回答 2

2

您实际上是在哪里将它插入到可视化树中?

Grid.Children.Add(_spatialFilterMode);
于 2012-08-07T02:28:33.937 回答
0

您是否必须将控件添加到某个父容器?

于 2012-08-07T02:25:02.430 回答