내 ViewModel에는 PlanTable - PlanTable 목록이 있습니다. DayPlan은 Day 및 List ExercisesWithReps 문자열을 포함합니다. ExercisesWithReps 문자열 이름과 목록 담당자의 포함내부 목록 상자 항목을 선택할 때 외부 목록 항목을 선택하는 방법은 무엇입니까?
I (나는 이미 한 일을)이 사용 목록 상자를 모두 표시 할 수 있도록하려면 :. screenshot
때 ExerciseName 또는 어떤 사용자가 클릭 reps (number), 나는이 2 개 중 하나를 캡처 할 수 있기를 원합니다. 또한 하루 (예 : 사용자가 tesst 아래에서 12를 클릭하면 월요일에 나타나기를 원합니다.)에서 운동을 클릭하면 화요일, 화요일도 선택하도록). 그러나 나는 그것을 어떻게 이해할 수 없다 .. 여기에 순간에
내 코드입니다 : VIEW : 상기 private List<DayPlan> planTable;
public List<DayPlan> PlanTable
{
get { return planTable; }
set
{
planTable = value;
RaisePropertyChanged();
}
}
public class DayPlan
{
public string Day { get; set; }
public List<Exercise> ExercisesWithReps { get; set; }
private Exercise selectedExerciseName;
public Exercise SelectedExerciseName
{
get { return selectedExerciseName; }
set
{
selectedExerciseName = value;
if (value != null)
{
TempExercise.Name = value.Name;
}
}
}
}
public class Exercise
{
public string Name { get; set; }
public List<int> Reps { get; set; }
private int selectedReps;
public int SelectedReps
{
get { return selectedReps; }
set
{
selectedReps = value;
TempExercise.Reps = value;
}
}
}
: 여기
<ListBox Name="lbParent" Grid.Row="1" Grid.ColumnSpan="3" ItemsSource="{Binding PlanTable}" SelectedItem="{Binding SelectedListItem, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Text="{Binding Day}" HorizontalAlignment="Center" Foreground="Black" Grid.Row="0" Margin="10"/>
<ListBox ItemsSource="{Binding ExercisesWithReps}" SelectedItem="{Binding SelectedExerciseName, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="{Binding Path=Name}" HorizontalAlignment="Center"/>
<ListBox ItemsSource="{Binding Reps}" BorderBrush="Transparent" SelectedItem="{Binding SelectedReps, UpdateSourceTrigger=PropertyChanged}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding }" HorizontalAlignment="Center"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
뷰 모델 및 DayPlan입니다 모든 순간 (Day, ExerciseName, Reps)을 선택해야만 사용자의 선택을 포착 할 수 있습니다. 또한, 나는 이름과 담당자를 캡처하고있어 방법은 DayPlan
의 SelectedExerciseName
속성이 설정 될 때마다
TreeView를 사용하면 훨씬 쉬울 것이라고 생각합니다. – sTrenat