我正在寻找以下示例:
我有一个带有listview的WPF窗口(或者实际上任何对象如果效果更好都会没问题)。 我有一个相当复杂的linq查询(我知道查询是正确的,因为我在Linqpad中测试过)。 在查询中有几个虚拟字段,我将不得不用补充查询填写。
我想:
Thanx寻求帮助。
标记
以下是窗口/对象的代码
public statesPerVersion(TPClient.Application _Application, TPlanPro.TPlanSession _Session, System.Collections.Generic.Dictionary<String, String> _dConnect, TPlanPro.Node _mvNode)
{
InitializeComponent();
_app = _Application;
_session = _Session;
_func = new CSNetFunctions.Functions(_session, _app, _dConnect);
TTNavDB01DataContext _navDB = new TTNavDB01DataContext(_dConnect[Functions._nav]);
var getStates = from s in _navDB.TP_MT_Scripts
join ss in _navDB.MT_ScriptStates on new { s.tpID, s.ComponentTC_ID } equals new { ss.tpID, ss.ComponentTC_ID }
join st in _navDB.MT_States on ss.StateID equals st.ID
join pr in _navDB.TE_ProductReleases on ss.ProductReleaseID equals pr.ProductReleaseId
//where s.TpMVersionID == "19E04398FB82435CB21A80EFEBAD62AF"
where s.tpMVersionID == _mvNode.Id.ToString()
orderby s.TestCaseID ascending, ss.ID descending
select new
{
s.ComponentTC_ID,
s.tpID,
s.TestCaseID,
ss.ID,
st.State,
ss.StateDate,
ss.StateBy,
pr.TeamTrackName,
ss.Comments,
Locked = true,
Bypassed = true,
s.ExternalScript,
s.EquContract,
s.FinContract,
s.ScriptType
} ;
var groupStates = from gs in getStates group gs by new { gs.TestCaseID } into gsGroup select new { ls = gsGroup.First() };
scriptList.DataContext = groupStates;
}
这是xaml的代码
Window x:Class="CSNetWindows.statesPerVersion"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="View latest Script states for Version " Height="267" Width="825">
<Grid>
<ListView x:Name="scriptList" HorizontalContentAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn Header="TestCase" Width="50"
DisplayMemberBinding="{Binding Path=ls.TestCaseID}" />
<GridViewColumn Header="State" Width="50"
DisplayMemberBinding="{Binding Path=ls.State}" />
<GridViewColumn Header="Date" Width="50"
DisplayMemberBinding="{Binding Path=ls.StateDate}" />
<GridViewColumn Header="Tester" Width="50"
DisplayMemberBinding="{Binding Path=ls.StateBy}" />
<GridViewColumn Header="Release" Width="50"
DisplayMemberBinding="{Binding Path=ls.TeamTrackName}" />
<GridViewColumn Header="Locked" Width="50"
DisplayMemberBinding="{Binding Path=ls.Locked}" />
<GridViewColumn Header="ByPassed" Width="50"
DisplayMemberBinding="{Binding Path=ls.ByPassed}" />
<GridViewColumn Header="External Script" Width="50"
DisplayMemberBinding="{Binding Path=ls.ExternalScript}" />
<GridViewColumn Header="Equ Contract" Width="50"
DisplayMemberBinding="{Binding Path=ls.EquContract}" />
<GridViewColumn Header="Fin Contract" Width="50"
DisplayMemberBinding="{Binding Path=ls.FinContract}" />
<GridViewColumn Header="Type" Width="50"
DisplayMemberBinding="{Binding Path=ls.FinContract}" />
<GridViewColumn Header="Comments" Width="50"
DisplayMemberBinding="{Binding Path=ls.ScriptType}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
答案 0 :(得分:0)
为什么你的LINQ查询返回一个List,其中SomeStruct表示你上面显示的结构,但允许你进行编辑等?然后在进行编辑后将它绑定到GridView。要将所选项目传递到下一个“页面”,您可能需要将所选项目存储在某个地方的全局变量中,然后从第二页中选择它。