XAML의 Silverlight Control은 런타임에 null입니다
-
06-09-2019 - |
문제
DeepEarth지도 컨트롤이있는 Silverlight 앱을 만들었습니다. 여기 내 기본 XAML이 있습니다
<Grid x:Name="LayoutRoot" >
<!-- Map Control -->
<DeepEarth:Map x:Name="map" Margin="0,0,0,0">
<Controls:CoordControl VerticalAlignment="Bottom" HorizontalAlignment="Right" />
<Controls:ScaleControl VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="12,12,12,40" />
</DeepEarth:Map>
<Controls:NavControl x:Name="navControl" >
<StackPanel Orientation="Horizontal">
<Button x:Name="MyButton" Content="Hi" Click="MyButton_Click"></Button>
</StackPanel>
</Controls:NavControl>
</Grid>
버튼에 첨부하고 싶은 동작 클래스가 있습니다.
public Page()
{
InitializeComponent();
new ButtonActionWithCancel(MyButton, new CreatePointCommand(map));
}
void MyButton_Click(object sender, RoutedEventArgs e)
{
if (MyButton == null) throw new Exception("Wat?");
}
이것은 MyButton에게 몇 가지 일을하고 일부 이벤트와 물건을 연결하기위한 것입니다. 문제는 MyButton이 런타임에 null이라는 것입니다. 어떻게 되나요? 계층 구조의 다른 컨트롤은 무효가 아닙니다. 무슨 일이야?
해결책
베타에서 벗어 났을 때 일어나지 않았습니다
제휴하지 않습니다 StackOverflow