作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Silverlight 的新手。我正在开发一个聊天应用程序,其中新的聊天消息被添加到列表的底部。我有一个工作版本,在 ScrollViewer 中用作 StackPanel,然后在后面的一些代码中使用 StackPanel.Children.Add()。
我正在尝试将其转换为 View-ViewModel 方法,但我不知道如何将 StackPanel 的 Children 绑定(bind)到任何集合属性。我试过这个:
<ScrollViewer Name="scrollMessages" Grid.Row="2" Margin="0,0,0,0" VerticalScrollBarVisibility="Visible">
<StackPanel x:Name="pnlMessages" Orientation="Vertical" Children="{Binding Path=ExampleTBs}" />
</ScrollViewer>
最佳答案
使用 ListBox
(或任何其他 ItemsControl
)并绑定(bind) ItemsSource
属性到 ObservableCollection
在您的 View 模型中。
关于silverlight - 如何从 ViewModel 绑定(bind) StackPanel Children?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214549/
我是一名优秀的程序员,十分优秀!