ok 간단히 말해서 내 페이지에 ToggleSwitch가 있습니다. 기본 값을 볼 수 나는xaml PhoneApplicationPage 코드의 속성에 Twoway 바인딩을 사용하는 경우
public partial class Setup : PhoneApplicationPage
{
public bool LocationTrackingEnabled
{
get { return (bool)GetValue(LocationTrackingEnabledProperty); }
set
{
SetValue(LocationTrackingEnabledProperty, value);
}
}
public static readonly DependencyProperty LocationTrackingEnabledProperty =
DependencyProperty.Register("LocationTrackingEnabled",
typeof(bool),
typeof(Setup),
new PropertyMetadata(false));
// blah blah rest of the page code follows on
다음 한 동일한 페이지의 뒤에있는 코드에서
<toolkit:ToggleSwitch x:Name="togLocation" VerticalAlignment="Center"
Style="{StaticResource gToggleSwitchStyle}" Foreground="{StaticResource brLightFont}"
Loaded="togLocation_Loaded" IsChecked="{Binding LocationTrackingEnabled, Mode=TwoWay}"/>
그래서 toggleswitch.IsChecked이 거짓이어야한다 false입니다. 사실이 아닙니다. 중단 점을 사용하여 LocationTrackingEnabled를 확인하면 바인딩이 아무런 변화도 일어나지 않습니다.
나는 코드에서 이것을 시도했다.
DataContext = this;
나는 또한 내가 전에 바인딩을 수행 한 페이지
DataContext="{Binding RelativeSource={RelativeSource Self}}"
의 XAML에서 이것을 시도했지만 나는이 문제를 볼 수 없습니다.
'LocationTrackingEnabled' 속성의 부모 클래스는 무엇입니까? –
은 PhoneApplicationPage입니다. 기본적으로 페이지에있는 토글 스위치는 코드에서 생성 된 페이지의 속성에 바인딩됩니다. – Gaz83