0
그룹 상자에 여러 텍스트 상자가 있습니다. 이 Textbox는 모두 Groupbox의 Datacontext에서 파생되지만 그룹의 Textbox 중 하나에는 다른 Datacontext가 필요합니다. 위의 코드에서 txtbA
부모 데이터 컨트롤의 datacontext를 로컬 datacontext로 대체합니다.
<GroupBox Header="My Group" Height="150" Width="1132" DataContext="{Binding ContextA}" >
<Grid>
<Label x:Name="lblA" Content="Policy Number:" Margin="6,12,970,92" />
<TextBox x:Name="txtbA" Margin="155,12,0,0" HorizontalAlignment="Left" Height="24" TextWrapping="Wrap" Text="{Binding ValueA}" VerticalAlignment="Top" Width="278" Grid.ColumnSpan="2"/>
<Label x:Name="lblB" Content="Policy Type:" Margin="612,10,334,88" Height="30"/>
<TextBox x:Name="txtbB" Margin="801,12,0,0" HorizontalAlignment="Left" Height="24" TextWrapping="Wrap" DataContext="{Binding ContextB}" Text="{Binding ValueB}" VerticalAlignment="Top" Width="278"/>
</Grid>
</GroupBox>
는 그룹 상자의 것과 동일한
Datacontext
이용한다. 내가
txtbB
별도의
Datacontext
즉
ContextB
을 갖고 싶어하지만 ContextB
이 txtbB
에 할당 받고 있지 않습니다. 문제를 해결하는 방법?
참고 : ContextA
및 ContextB
= Entity Framework 모델 목록.