XAML (Silverlight 4)에서 종속성 속성을 설정하고 있습니다.Silverlight : 종속성 속성은 언제 사용할 수 있습니까?
<my:TopSearchBar x:Name="topSearchBar" Grid.Row="0" Navigator="{Binding ElementName=navigationFrame}" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
navigationFrame
의 일부 탐색 이벤트에 등록해야합니다. 그러나 다음은 널 포인터 예외로 실패합니다.
public TopSearchBar()
{
// Required to initialize variables
InitializeComponent();
Loaded += new RoutedEventHandler(TopSearchBar_Loaded);
}
void TopSearchBar_Loaded(object sender, RoutedEventArgs e)
{
// Navigator is null
Navigator.Navigated += new NavigatedEventHandler(Navigated);
}
이 이벤트 핸들러를 등록 할시기는 언제입니까? 나는 속성 설정자에서 그것을 시도했지만 그 중단 점은 결코 부딪치지 않았다 :
public Frame Navigator
{
get { return GetValue(NavigatorProperty) as Frame; }
set { SetValue(NavigatorProperty, value); }
}