Yawar
Yawar

Reputation: 1943

Pivot control header icon of un selected pivot in windows phone universal application

I have pivot control in my universal windows phone application. Defined like this

                <PivotItem.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Margin="0 0 10 0" Width="40" Source="/Assets/Images/cher.png" />
                        <TextBlock x:Uid="cherTextBlock" Grid.Column="1" Style="{StaticResource PivotHeadingStyle}" />
                    </Grid>
                </PivotItem.Header>

When I am on first pivot the text of second pivot becomes dull. But offcourse the image doesn't become dull. I have same image with dull effect and I want that dul image to be shown when other pivot is shown.

One approach is that I make it programmatically and change the source of image when it is not in focus. But I want to know is that possible to do this in xaml or some other better approach than mine?

Upvotes: 0

Views: 426

Answers (1)

Yawar
Yawar

Reputation: 1943

Accomplished it like programmatically

inside initialized component added this code

//RechargeAccountPivot is name of my pivot control.
RechargeAccountPivot.SelectionChanged += RechargeAccountPivot_SelectionChanged;

And this is selectionChanged event code. where i gave names to my all image controls and changed their icons.

private void RechargeAccountPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (RechargeAccountPivot.SelectedIndex == 0)
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCard.png"));// new BitmapImage { UriSource = new Uri("//Assets/Images/BalanceTopUpIcons/rechargeCard.png") };
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
        }
        else if (RechargeAccountPivot.SelectedIndex == 1)
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCardDull.png"));
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucher.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
        }
        else
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCardDull.png"));
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucher.png"));
        }
    }

Upvotes: 1

Related Questions