1

I have two radio buttons n my XAML like this:

                <RadioButton x:Name="Radio1"
                         Margin="12,46,30,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Content="Radio1"
                         GroupName="Group1"
                         IsChecked="True" />

            <RadioButton x:Name="Radio2"
                         Margin="12,46,0,0"
                         HorizontalAlignment="Left"
                         VerticalAlignment="Top"
                         Content="Radio2"
                         GroupName="Group1"
                         IsChecked="False" />

I want to display a different Grid for each radio button Checking so I bind Grid Visibility to RadioButton IsChecked property like this:

            <Grid Name="Grid1"
              Grid.Row="1"
              Visibility="{Binding IsChecked,

                                   Converter={StaticResource visibilityConverter},
                                   ElementName=Radio1}">


            <Grid Name="Grid2"
              Grid.Row="1"
              Margin="0,50,0,0"
              Visibility="{Binding IsChecked,
                                   Converter={StaticResource visibilityConverter},
                                   ElementName=Radio2}">

It works properly but I have problem. The first time I load this page the two grids appear for apart of second then the non checked one disappear. It seems that Visibility of Grid set for default value then it change after drawing according to binding. Is there any solution for this or workaround?

Note: this solution is Windows Phone 8 solution

4

0 回答 0