我有一个UI象下面这样:通过控制绘制垂直线
问题是目前的线分割除非屏幕被填充来自该消息的名称是不可见的(其基本上自定义控件上的边框)。
我想为父控制(stackpanel
)永久拥有一条线,而不必在每个MessageControl
上使用边框。
这可能吗?
下面是stackpanel
代码:
<UserControl x:Class="ChatBoxWPF.ChatWindow"
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="402" d:DesignWidth="700" xmlns:my="clr-namespace:ChatBoxWPF" VerticalContentAlignment="Stretch" VerticalAlignment="Stretch">
<ScrollViewer>
<StackPanel Name="Messages" VerticalAlignment="Bottom"></StackPanel>
</ScrollViewer>
</UserControl>
更新1:
我尝试这样做:
<ScrollViewer Name="scroll">
<StackPanel Name="Messages" VerticalAlignment="Bottom">
<Line StrokeThickness="1" X1="100" Y1="0" X2="100" Y2="{Binding ElementName=scroll, Path=ActualHeight}" />
</StackPanel>
</ScrollViewer>
没有电网。它现在有时会在设计师中展示,而其他时间则不会。而当运行并没有显示出来。我需要网格吗?
可以添加spiltter,检查这个http://learnwpf.com/post/2006/05/08/How-Do-I-Add-a-Splitter-to-my-WPF-Window.aspx –
@Ravi这将是可怕的。他只需要图形,而不是完整的分割器功能。看到这个问题的答案:http://stackoverflow.com/questions/3702140/draw-lines-and-circles-in-wpf(ps谷歌搜索花费的时间比它会让我写你的问题) – SimpleVar
@ YoryeNathan说,这个链接是我自己的问题! – sprocket12