2010-11-28 2 views
1

WP7 컨트롤 툴킷에서 아래와 같이 두 개의 toggleSwitches를 사용하고 있습니다. 첫 번째 토글을 기반으로 두 번째 토글 스위치가 활성화 또는 비활성화되어야합니다. 두 번째 토글 스위치를 사용하지 않도록 설정하면 제대로 작동하지만 사용하도록 설정하면 텍스트 전경이 변경되지 않습니다. 왜 이런 일이 일어나는지 알아 내도록 도와주세요. 당신이ToggleSwitch - 텍스트를 활성화하는 방법?

toggleTwitterAutoPublish.IsChecked = isAutoPublish; 

을 할 때 (AlterTwitterControlsDisplay 기능의 다른 부분에)

toggleTwitterAutoPublish.IsChecked = false; 

일을

<!--ContentPanel - place additional content here--> 
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
    <toolkit:ToggleSwitch Header="twitter" Margin="10,15,0,0" Name="toggleTwitter" Checked="toggleTwitter_Checked" Unchecked="toggleTwitter_Unchecked"> 
     <toolkit:ToggleSwitch.HeaderTemplate> 
      <DataTemplate> 
       <ContentControl FontSize="{StaticResource PhoneFontSizeLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Content="{Binding}"/> 
      </DataTemplate> 
     </toolkit:ToggleSwitch.HeaderTemplate> 
     <toolkit:ToggleSwitch.ContentTemplate> 
      <DataTemplate> 
       <StackPanel> 
        <StackPanel Orientation="Horizontal"> 
         <TextBlock Text="Status: " FontSize="{StaticResource PhoneFontSizeMedium}"/> 
         <ContentControl HorizontalAlignment="Left" FontSize="{StaticResource PhoneFontSizeMedium}" Content="{Binding}"/> 
        </StackPanel> 
       </StackPanel> 
      </DataTemplate> 
     </toolkit:ToggleSwitch.ContentTemplate> 
    </toolkit:ToggleSwitch> 
    <toolkit:ToggleSwitch Header="" Margin="10,100,0,-35" Name="toggleTwitterAutoPublish" Checked="toggleTwitterAutoPublish_Checked" Unchecked="toggleTwitterAutoPublish_Unchecked"> 
     <toolkit:ToggleSwitch.ContentTemplate> 
      <DataTemplate> 
       <StackPanel> 
        <StackPanel Orientation="Horizontal"> 
         <TextBlock Text="Auto Publish: " FontSize="{StaticResource PhoneFontSizeMedium}" Margin="0,-15,0,0" /> 
         <ContentControl HorizontalAlignment="Left" FontSize="{StaticResource PhoneFontSizeMedium}" Content="{Binding}" IsEnabled="{Binding}" Margin="0,-15,0,0"/> 
        </StackPanel> 
       </StackPanel> 
      </DataTemplate> 
     </toolkit:ToggleSwitch.ContentTemplate> 
    </toolkit:ToggleSwitch> 
</Grid> 


public partial class MainPage : PhoneApplicationPage 
{ 
    bool isConnected = false; 
    bool isAutoPublish = false; 

    public const string SIGNED_IN_MESSAGE = "Signed In"; 
    public const string SIGNED_OUT_MESSAGE = "Signed Out"; 
    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 
    } 

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) 
    { 
     toggleTwitter.IsChecked = isConnected; 

     AlterTwitterControlsDisplay(); 

     base.OnNavigatedTo(e); 
    } 


    #region Twitter 

    private void AlterTwitterControlsDisplay() 
    { 
     if (toggleTwitter.IsChecked.Value) 
     { 
      toggleTwitter.Content = SIGNED_IN_MESSAGE; 
      toggleTwitterAutoPublish.IsEnabled = true; 
      toggleTwitterAutoPublish.IsChecked = isAutoPublish; 
     } 
     else 
     { 
      toggleTwitter.Content = SIGNED_OUT_MESSAGE; 
      toggleTwitterAutoPublish.IsEnabled = false; 
      toggleTwitterAutoPublish.IsChecked = false; 
     } 
    } 

    private void toggleTwitter_Checked(object sender, RoutedEventArgs e) 
    { 
     isConnected = true; 
     AlterTwitterControlsDisplay(); 
    } 

    private void toggleTwitter_Unchecked(object sender, RoutedEventArgs e) 
    { 
     isConnected = false; 
     AlterTwitterControlsDisplay(); 
    } 

    private void toggleTwitterAutoPublish_Checked(object sender, RoutedEventArgs e) 
    { 
     isAutoPublish = true; 
    } 

    private void toggleTwitterAutoPublish_Unchecked(object sender, RoutedEventArgs e) 
    { 
     isAutoPublish = false; 
    } 

    #endregion Twitter 
} 
+0

나는 정확히 같은 문제가있어. 나는 해결책을 알고 싶다 – Doug

+0

나는 문제가 무엇인지 명확하지 않다. 두 번째 토글 스위치가 활성화 또는 비활성화되면이 코드로 포 그라운드 색상이 변경됩니다. –

+0

매트와 동의하십시오. 상태 : 로그 아웃 한 경우 전경 회색이며 그렇지 않은 경우 흰색입니다 (자동 게시 On/Off). 예상 된 행동이 아닌가? –

답변

1

toggleTwitterAutoPublish_UncheckedisAutoPublish = false

따라서 다음 번에 설정하는 트리거 여기 isAutoPublish은입니다.210 따라서 원하는 결과를 얻지 못할 수도 있습니다.

귀하의 질문에서 내가 이해 한 바입니다. 이것이 문제가 아니라면 명확하게 설명하십시오. 희망이 도움이

관련 문제