填充窗口的列
我想做的是在窗口中填充两列。此列将包含全局变量的名称及其路径。我在窗口中显示我需要的内容时遇到问题。
<TabItem Header="Global Variables" GotFocus="GlobalVariablesTab_GotFocus">
<dc:TreeListView Name="tvwGlobalVariables" dc:ColumnLayoutManager.Enabled="True" >
<dc:TreeListView.Columns>
<!--First Column. -->
<dc:StdGridViewColumn Header="Variable" Width="200" >
<dc:StdGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextTrimming="CharacterEllipsis"/>
</DataTemplate>
</dc:StdGridViewColumn.CellTemplate>
</dc:StdGridViewColumn>
<!-- Second Column-->
<dc:StdGridViewColumn Header="Result" dc:ColumnRange.IsFillColumn="True"/>
</dc:TreeListView.Columns>
</dc:TreeListView>
</TabItem>
这是包含我需要填充的区域的选项卡。第一列用于名称,第二列用于路径。我可能也错过了一些东西。
private void GlobalVariablesTab_GotFocus(object sender, RoutedEventArgs e)
{
lvGlobals.Items.Clear();
sman = SchemaManager.SchemaManager.GetInstance();
IEnumerator enumerator = sman.GetGlobalVariableEnumerator();
while (enumerator.MoveNext())
{
DictionaryEntry entry = (DictionaryEntry) enumerator.Current;
ListViewItem lvi = new ListViewItem();//new string[] {entry.Key.ToString(), entry.Value.ToString()});
lvi.Tag = entry.Key.ToString() + entry.Value.ToString();
}
}
目前我有 lvi 持有这两个部分,但我需要一个部分进入第一列,另一个部分进入另一列。如果我不需要的话我就不打算保留lvi。无论哪种方式,我都需要在第一列中显示 entry.key
,在第二列中显示 entry.value
。有什么想法吗?
What I am trying to do is populate two columns in a window. This columns will have the name of the global variable and the path it to it. I am having problems displaying what I need in the windows.
<TabItem Header="Global Variables" GotFocus="GlobalVariablesTab_GotFocus">
<dc:TreeListView Name="tvwGlobalVariables" dc:ColumnLayoutManager.Enabled="True" >
<dc:TreeListView.Columns>
<!--First Column. -->
<dc:StdGridViewColumn Header="Variable" Width="200" >
<dc:StdGridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock TextTrimming="CharacterEllipsis"/>
</DataTemplate>
</dc:StdGridViewColumn.CellTemplate>
</dc:StdGridViewColumn>
<!-- Second Column-->
<dc:StdGridViewColumn Header="Result" dc:ColumnRange.IsFillColumn="True"/>
</dc:TreeListView.Columns>
</dc:TreeListView>
</TabItem>
This is the tab that has the area I need to populate. The first column for the name and the second will be for the path. I may be missing something as well.
private void GlobalVariablesTab_GotFocus(object sender, RoutedEventArgs e)
{
lvGlobals.Items.Clear();
sman = SchemaManager.SchemaManager.GetInstance();
IEnumerator enumerator = sman.GetGlobalVariableEnumerator();
while (enumerator.MoveNext())
{
DictionaryEntry entry = (DictionaryEntry) enumerator.Current;
ListViewItem lvi = new ListViewItem();//new string[] {entry.Key.ToString(), entry.Value.ToString()});
lvi.Tag = entry.Key.ToString() + entry.Value.ToString();
}
}
Currently I have lvi holding both parts but I will need one part to go to the first column and the other part to the other column. I don't intend to keep lvi if I don't need it. Either way I need to get entry.key
displayed in the first column and entry.value
in the second. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道 SchemaManager 是什么,所以我只是使用带有一些虚拟数据的哈希表来获取带有一些字典条目的枚举器。下面的示例代码使用常规的 WPF 列表视图,其中有两列,没有格式设置以保持简单。
XAML:
隐藏代码:
I don't know what the SchemaManager is so I just used a Hashtable with some dummy data to get an enumerator with some dictionary entries. Below sample code uses a regular WPF listview with two columns with no formatting to keep it simple.
XAML:
Code behind: