【发布时间】:2019-12-11 00:01:39
【问题描述】:
我在 xaml 中有一个窗口:
<view:ToolBar DataContext="{Binding}"/>
<Grid>
<ListView>
<ListView.View>
<GridView>
<GridViewColumn>
....//all the columns
</GridView>
</ListView.View>
</ListView>
</Grid>
工具栏是一个继承自用户控件的类。在toolbar.xaml 中,我有一个按钮,它有一个命令。
<ToggleButton Style="{DynamicResource ToggleButtonStyle}"
IsChecked="{Binding Checked}"
Command="{x:Static ui:GridHelper.UpdateColumns}">
</ToggleButton>
每次单击该按钮时,我都想将列表视图的列标题传递给命令。但我不知道如何连接工具栏和列表视图,因为它们完全分开。有任何想法吗?谢谢!
【问题讨论】:
-
也许你应该使用一个视图模型来保存这种信息,比如列标题和列数据。其他控件可以轻松绑定到这些数据。