0
所以我试图制作一个程序,允许用户使用WPF中不同功能的模块设计简单程序。WPF - 如何以编程方式在自定义控件之间绘制线条
我创建的自定义控件我的模块,像这样:
<Border Height="75" Width="150" BorderThickness="1" BorderBrush="Black">
<Grid Background="Gray" Height="75" Width ="150">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Label Content="Double" FontSize="12" Grid.Row="0" HorizontalContentAlignment="Center" Background="Aquamarine"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Name="IncomingConnection" Height="15" Width="15" Background="Black" Margin="5" VerticalAlignment="Top" HorizontalAlignment="Left"/>
<Button Name="OutgoingConnection" Grid.Column="2" Height="15" Width="15" VerticalAlignment="Top" Background="Black" Margin="5" HorizontalAlignment="Right"/>
<Button Name="OutgoingData" Grid.Column="2" Height="15" Width="15" VerticalAlignment="Bottom" Background="Aquamarine" Margin="5" HorizontalAlignment="Right"/>
</Grid>
</Grid>
</Border>
不管怎么说,我希望能够点击这些按钮(incomingConnection或outgoingConnection)中的一个,并有连接线两个按钮。
其他信息:自定义控件全部放在拇指内,以便可以拖动它们。一切都在画布上。我不想在控件之间创建一条线,而是在控件上的按钮之间创建一条线。
谢谢!
你试了一下自己?你有没有实现一些[命令](http://stackoverflow.com/questions/7660547/how-to-create-bindable-commands-in-custom-control)? –
大部分只是研究,我发现可能工作的所有东西似乎是整个控件的专属,而不是针对特定的按钮。我试图在按下按钮时获取该按钮的点,但是一旦控件被拖动到其他地方,该按钮就不起作用。 –