Хорошо, у меня есть 2 сетки данных wpf, подобные этому
<GroupBox Header="Generel" Grid.Row="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="53*"/>
<ColumnDefinition Width="86*"/>
</Grid.ColumnDefinitions>
<DataGrid Name="dgCellIDMeterCount"
ItemsSource="{Binding Path=CellIDMeterCount}"
Margin="0,0,0,0"
AutoGenerateColumns="False"
HorizontalAlignment="Left"
SelectionMode="Single"
SelectedItem="{Binding Mode=TwoWay, Path=CurrentCellID}"
Grid.Row="0"
Grid.ColumnSpan="1"
CellStyle="{StaticResource DataGridCellStyle}"
IsReadOnly="True" Width="100">
<DataGrid.Columns>
<DataGridTextColumn Header="CellID" Binding="{Binding Key}"/>
<DataGridTextColumn Header="Meters" Binding="{Binding Value}"/>
</DataGrid.Columns>
</DataGrid>
<DataGrid Name="dgMetersOnCellID"
ItemsSource="{Binding Path=CurrentCellID.GetMetersOnCurrentCellID}"
Margin="10,0,0,0"
AutoGenerateColumns="False"
HorizontalAlignment="Left"
SelectionMode="Single"
CellStyle="{StaticResource DataGridCellStyle}"
IsReadOnly="True"
Width="100"
Grid.Column="1"/>
</Grid>
</GroupBox>
Что я хочу сделать, так это выбрать элемент в первой сетке данных, использовать этот элемент, чтобы найти данные, которые я хочу, во второй сетке данных. У меня есть метод, который может найти нужные данные, но я не знаю, как его связать, чтобы возвращаемое значение отображалось после выбора?
Метод
public List<Meter> GetMetersOnCurrentCellID()
{
return meters.Where(x => x.Gsmdata.Last()
.CellID == CurrentCellID.Key)
.ToList();
}
и свойства, к которым я привязываюсь в текущих сетках данных wpf
public KeyValuePair<int, int> CurrentCellID
{
get { return currentCellID; }
set
{
currentCellID = value;
OnPropertyChanged("CurrentCellID");
}
}
public Dictionary<int, int> CellIDMeterCount
{
get { return cellidMeterCount; }
set
{
cellidMeterCount = value;
OnPropertyChanged("CellIDMeterCount");
}
}
GetMetersOnCurrentCellID()
это метод. В WPF вы можете связываться только со свойствами, а не с методами. - person Rohit Vats   schedule 01.04.2014