The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Checking specific radiobutton when navigate to page RRS feed

  • Question

  • In a windows 8.1 project i have a ListView that displays several items that look something like this:

    enter image description here

    I basically display agenda points, that can have 2 sub levels

    if subpoint at first level has no subpoints itself it is a radiobutton, otherwise the subpoints it contains are radiobuttons.

    the radiobutton points have this template.

    <DataTemplate x:Key="WithSubTemplate2">
    
            <Grid Width="280" Height="50" Margin="85,0,0,0" HorizontalAlignment="Right">
    
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="5" />
                </Grid.RowDefinitions>
    
                <RadioButton GroupName="meetingFiles" Tag="{Binding}"  Checked="RadioButton_Checked" Content="{Binding Name}" Style="{StaticResource RadioButtonStyle1}"></RadioButton>
                <Ellipse Width="20" Height="20" Fill="#b3d0dd" HorizontalAlignment="Right" Margin="0,0,10,0"></Ellipse>
                <TextBlock Text="{Binding AttachmentNumber}" HorizontalAlignment="Right"  FontFamily="Segoe UI Regular" FontSize="16" Foreground="{StaticResource BrandBrush}" Margin="0, 14,15,0"></TextBlock>
                <Grid x:Name="whiteLine" Grid.Row="1" Width="270" Height="1" Background="#80b0c6" HorizontalAlignment="Center" />
            </Grid>
        </DataTemplate>

    When i check one of the radio buttons, i have a control that displays a pdf, and then when i want to edit that pdf it navigates to another page.

    What i want is, when i go back to the previous page to have the RadioButton i checked earlier to be checked when the page opens.

    Any way i can achieve this?

    Monday, December 7, 2015 2:20 PM

All replies

  • Hi,

    You can do it by setting NavigationCacheMode to Required/Enabled.

    Reference: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.page.navigationcachemode?f=255&MSPPError=-2147217396


    Hope this helps!

    Monday, December 7, 2015 4:10 PM
  • thanks for the reply

    yes, this was the first thing i tried, but it caused some other issues, like some "Access Violations" when the pdf file opens. I was trying to find a way of getting all RadioButtons, and search for a specific one
    Monday, December 7, 2015 4:58 PM
  • hi,

    Try to bind IsChecked property of RadioButton and tracking this property value in your View Model.

    <DataTemplate x:Key="WithSubTemplate2">
    
            <Grid Width="280" Height="50" Margin="85,0,0,0" HorizontalAlignment="Right">
    
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="5" />
                </Grid.RowDefinitions>
    
                <RadioButton GroupName="meetingFiles" Tag="{Binding}" IsChecked={Binding IsChecked, Mode=TwoWay}" Checked="RadioButton_Checked" Content="{Binding Name}" Style="{StaticResource RadioButtonStyle1}"></RadioButton>
                <Ellipse Width="20" Height="20" Fill="#b3d0dd" HorizontalAlignment="Right" Margin="0,0,10,0"></Ellipse>
                <TextBlock Text="{Binding AttachmentNumber}" HorizontalAlignment="Right"  FontFamily="Segoe UI Regular" FontSize="16" Foreground="{StaticResource BrandBrush}" Margin="0, 14,15,0"></TextBlock>
                <Grid x:Name="whiteLine" Grid.Row="1" Width="270" Height="1" Background="#80b0c6" HorizontalAlignment="Center" />
            </Grid>
        </DataTemplate>


    Monday, December 7, 2015 5:31 PM
  • I binded my IsChecked property, but im not sure how that will help me
    Tuesday, December 8, 2015 10:04 AM