2012-11-19 2 views
1

내 컨트롤 (MyControl)을 기준으로 UserControl. 여기에는 myListBox이라는 이름의 ListBox 항목이 포함되어 있습니다. Window에서 MyControl 인스턴스를 myControlInstance 변수로 배치했습니다. 이 창에는 appInfo 변수라는 이름의 다른 컨트롤이 들어 있습니다. appInfo.SomePropertyMyControl.myListBox.SelectedItem으로 바인딩해야합니다. XAML을 통해 어떻게 할 수 있습니까?WPF : 중첩 된 개체의 속성에 바인딩

DataContext="{Binding ElementName=myControlInstanceName, 
Path=myListBox.SelectedItem}" 

을하지만 그것은 작동하지 않습니다 :

나는 그것을 시도. XAML을 통해 문제를 어떻게 해결할 수 있습니까?

+0

'의 X : FieldModifier = "공개"'. –

+0

다음 XAML 코드를 통해이 문제를 해결했습니다. 'DataContext = "{Binding ElementName = myControlInstanceName, Path = Content.Children [1] .SelectedItem}"/>' 하지만 인덱스를 사용하지 않고하고 싶습니다 ... –

+0

더 나은 접근 방식은 DependencyProperty로 SelectedItem을 실현합니다. – Eugene

답변

0

나는 다음 XAML 코드를 통해 그것을 해결 : DataContext="{Binding ElementName=myControlInstanceName, Path=Content.Children[1].SelectedItem}"

관련 문제