我正在生产过程控制系统的图形,我想要创建一个系统边界,它可以在视觉上包裹在过程模拟中显示的各种子系统。除此之外,我可以使用常规边框,除了改变反映系统状态的颜色外,还会弹出指示处于报警状态的系统部件的小“气球”。WPF用户控件扩展边界类。 “不支持直接内容”?
我创建与用户控制一个测试项目,并添加了列表框(用于气球),并包裹在边界控制一个ContentPresenter元件。但是,每当我在另一个应用程序中使用这个新控件时,它都不允许我向它添加内容。我试着用ContentPropertyAttribute和ContentPresenter元素的属性来搞乱一些,但我觉得我在这里是盲人。
<UserControl x:Class="SystemStatusBorder.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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Canvas Height="290" Width="303">
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ContentPresenter/>
</Border>
<ListBox Canvas.Right="0" Canvas.Bottom="0">
<ListBox.RenderTransform>
<TranslateTransform X="20"></TranslateTransform>
</ListBox.RenderTransform>
<ListBoxItem>TagA</ListBoxItem>
<ListBoxItem>TagB</ListBoxItem>
</ListBox>
</Canvas>
</UserControl>
我不明白。除了contentpresenter的存在之外,还需要什么? UserControl的子类ContentControl,所以我会认为布线已经到位。最后,我希望它是用这样的:
<SystemBorder>
<SystemBorder.MonitoredTags>
<List of relevant tags for the specific sub system goes here>
</SystemBorder.MonitoredTags>
<regular content goes here>
</SystemBorder>
非常感谢!不能等待检查出来。 – Tormod 2011-03-17 05:20:17