可以在Stackpanel中查看整个对象吗?
我是WPF中的新手,试图创建他的第一个正常项目,即注释申请。 每个音符都链接到按钮
,我认为它在stackpanel
中看起来很漂亮。 我正在在stackpanel
中动态创建按钮
s,但是问题是当我向下滚动button
s last button的列表时/代码>无法完全看到。我以为是因为
and 保证金
并试图对其进行调整,但没有帮助,auto
height
width
无济于事。 stackpanel
在scrollviewer
中,当我到达scrollbar
的结尾时,我只能看到最后一个按钮的一半?
这是stackpanel
's xaml代码:
<ScrollViewer VerticalScrollBarVisibility="Auto"
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="50 -50 50 5" >
<StackPanel x:Name="ButtonPanel"/>
</ScrollViewer>
这就是我创建button
:
dynamicTextBox.Add(SearchNotes);
dynamicTextBox[index_of_buttons] = new TextBox();
Grid.SetRow(dynamicTextBox[index_of_buttons], 1);
Grid.SetColumn(dynamicTextBox[index_of_buttons], 0);
this.ButtonPanel.Children.Add(dynamicTextBox[index_of_buttons]);
dynamicTextBox[index_of_buttons].IsReadOnly = false;
dynamicTextBox[index_of_buttons].Text = "";
where dynamictextbox
is code> list&lt;&gt;
textbox
es应用模板(我认为没有必要查看模板解决问题)
这就是外观: 看不到整个按钮(最后一个),
所以我想看看整个按钮。
I am a newbie in WPF trying to create his first normal project which is a notes application.
Every note is linked to a button
and I thought it'll look beautiful in StackPanel
.
I am dynamically creating button
s within StackPanel
, but the problem is that when I scroll down the list of Button
s last Button
can't be seen fully. I thought it was because of the Margin
and tried to adjust it, but it didn't help, also auto
Height
and Width
didn't help. StackPanel
is within ScrollViewer
and when I reach the end of ScrollBar
I just can see half of last button ?
Here is StackPanel
's XAML code:
<ScrollViewer VerticalScrollBarVisibility="Auto"
Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Grid.RowSpan="3" Margin="50 -50 50 5" >
<StackPanel x:Name="ButtonPanel"/>
</ScrollViewer>
That is how I create Button
:
dynamicTextBox.Add(SearchNotes);
dynamicTextBox[index_of_buttons] = new TextBox();
Grid.SetRow(dynamicTextBox[index_of_buttons], 1);
Grid.SetColumn(dynamicTextBox[index_of_buttons], 0);
this.ButtonPanel.Children.Add(dynamicTextBox[index_of_buttons]);
dynamicTextBox[index_of_buttons].IsReadOnly = false;
dynamicTextBox[index_of_buttons].Text = "";
Where dynamicTextBox
is List<>
of TextBox
es to which is applied Template(I think it is not necessary to see Template to resolve the problem)
This is how it looks like:
Can't see the whole button(the last one)
So I wanna see the whole button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如Andy在评论部分中所写的那样,
ListBox
是解决此问题的最佳解决方案。我尝试了这个使它看起来与Stackpanel
Xaml中完全相同:
c#:
这是最后的最后按钮看起来像现在
As Andy wrote in the comment section,
ListBox
is best solution for this problem.I tried this one to make it look like exactly same as it was in StackPanel
Xaml:
C#:
This is how last button looks like now