Changing RequestedTheme from C# affects Pivot Margins

This is a universal app.
I created a style for PivotItem and Pivot that set Margin and Padding to 0.
I've setup a dark and light theme.
I can change the RequestedTheme to either in App.xaml and it works fine.
If I change the RequestedTheme of the App's Root frame during run time, the margin and padding of the pivot are reset.
The left image is how it should look, the right image is how it looks after changing theme at runtime.
switch(App.AppDataSerializer.AppData.Config.SelectedApplicationTheme)
case 0:
default:
App.RootFrame.RequestedTheme = Windows.UI.Xaml.ElementTheme.Light;
break;
case 1:
App.RootFrame.RequestedTheme = Windows.UI.Xaml.ElementTheme.Dark;
break;
<Style
x:Key="PivotItemNoMarginStyle"
TargetType="PivotItem">
<Setter
Property="Background"
Value="Red" />
<Setter
Property="Margin"
Value="0" />
<Setter
Property="Padding"
Value="0" />
<Setter
Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter
Property="VerticalContentAlignment"
Value="Stretch" />
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="PivotItem">
<Grid
Background="{TemplateBinding Background}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup
x:Name="Pivot">
<VisualState
x:Name="Right" />
<VisualState
x:Name="Left" />
<VisualState
x:Name="Center" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="0"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="PivotNoMarginStyle"
TargetType="Pivot">
<Setter
Property="Margin"
Value="0" />
<Setter
Property="Padding"
Value="0" />
<Setter
Property="Foreground"
Value="{ThemeResource PhoneForegroundBrush}" />
<Setter
Property="Background"
Value="Blue" />
<Setter
Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Grid />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="Pivot">
<Grid
x:Name="RootElement"
Background="{TemplateBinding Background}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Grid.RowDefinitions>
<RowDefinition
Height="Auto" />
<RowDefinition
Height="*" />
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup
x:Name="Orientation">
<VisualState
x:Name="Portrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="Margin"
Storyboard.TargetName="TitleContentControl">
<DiscreteObjectKeyFrame
KeyTime="0"
Value="{ThemeResource MyPivotPortraitThemePadding}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState
x:Name="Landscape">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="Margin"
Storyboard.TargetName="TitleContentControl">
<DiscreteObjectKeyFrame
KeyTime="0"
Value="{ThemeResource MyPivotLandscapeThemePadding}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentControl
x:Name="TitleContentControl"
ContentTemplate="{TemplateBinding TitleTemplate}"
Content="{TemplateBinding Title}"
Style="{StaticResource PivotTitleContentControlStyle}" />
<ScrollViewer
x:Name="ScrollViewer"
HorizontalSnapPointsAlignment="Center"
HorizontalSnapPointsType="MandatorySingle"
HorizontalScrollBarVisibility="Hidden"
Margin="{TemplateBinding Padding}"
Grid.Row="1"
Template="{StaticResource ScrollViewerScrollBarlessTemplate}"
VerticalSnapPointsType="None"
VerticalScrollBarVisibility="Disabled"
VerticalScrollMode="Disabled"
VerticalContentAlignment="Stretch"
ZoomMode="Disabled">
<PivotPanel
x:Name="Panel"
VerticalAlignment="Stretch">
<PivotHeaderPanel
x:Name="Header">
<PivotHeaderPanel.RenderTransform>
<CompositeTransform
x:Name="HeaderTranslateTransform"
TranslateX="0" />
</PivotHeaderPanel.RenderTransform>
</PivotHeaderPanel>
<ItemsPresenter
x:Name="PivotItemPresenter">
<ItemsPresenter.RenderTransform>
<TranslateTransform
x:Name="ItemsPresenterTranslateTransform"
X="0" />
</ItemsPresenter.RenderTransform>
</ItemsPresenter>
</PivotPanel>
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

The solution I came up with was to run this function in the Page.Loaded event handlers for each page with a Pivot
public static void ResetPivotItemMargins(DependencyObject obj)
var pivots = Zorn.Universal.VisualTreeUtil.FindElementsOfType<Pivot>(obj);
if (pivots.Any())
var pivotItems = pivots.First().Items;
foreach (PivotItem pivotItem in pivotItems)
pivotItem.Margin = new Thickness(0, 0, 0, 0);
public static List<T> FindElementsOfType<T>(DependencyObject parentElement) where T : DependencyObject
List<T> items = new List<T>();
var count = VisualTreeHelper.GetChildrenCount(parentElement);
if (count == 0)
return items;
for (int i = 0; i < count; i++)
var child = VisualTreeHelper.GetChild(parentElement, i);
if (child != null && child is T)
items.Add((T)child);
var result = FindElementsOfType<T>(child);
if (result.Count > 0)
items.AddRange(result);
return items;

Similar Messages

  • Agents state getting changed automatically from NotReady to Ready

    Agents state getting changed automatically from NotReady to Ready on random position during break time. Can some help me out?
    UCCE version 8.5 

    Hello Ahmad,
    Bug below describes a scenario where the agent is transitioned to the Ready state without manually changing it.
    Also effects 8.5.
    CSCty97770
    Save Bug
    UCCX: Agent Incorrectly Set To Ready After RNA On ICD Extension
    Symptom:
    A Unified Contact Center Express (UCCX) agent may transition to the Ready state without manual intervention.
    Conditions:
    This occurs when, while on a call on the personal line, the agent receives a consult transfer from another agent on the ICD line, does not answer this call and the call is disconnected by the calling agent. When processing this disconnect, the agent state is incorrectly transitioned to Ready even though the call is still in progress ...more
    Details
    Known Affected Releases: (2)
    8.5(1)SU2 | 8.0(2)SU4
    Known Fixed Releases: (1)
    9.0(.96000.398)
    Product: Cisco Unified Contact Center Express
    Hope this helps,
    Please rate helpful posts.
    Thanks.

  • Card Images Become "Unopenable" on Notebook After Changing View From "Details" to "Medium Icons"

    I've been viewing & placing image files into folders directly from my camera card over the past few days on my new notebook. It was becoming very tedious as I had to view each image seperately to see what it was, before I had the bright idea to try to "VIEW" them differently. In the process of changing the "VIEW" from "DETAILS" to "MEDIUM ICONS", some of the the pictures which had previously been fine the few times I had taken the card in & out of the notebook, became HP Icons instead of the picture's thumbnail. I didn't realize this at first because the pictures were broken up into months (luckily), I  was going through them chronilogically, and it wasn't until I got to images from the 26th of that month that I came across this problem. I clicked the HP logo for these images and got the message "SORRY, WE CANNOT OPEN THIS PHOTO". I immediately panicked and closed the folders and took the card out to put back into my camera to see if it showed up on there. Sure enough where those images had been was replaced with a big question mark and the message "Unidentified Image" when I selected it to view. I immediately went through every picture on the camera to see if this had happened to images from other months, but it had not. I had no clue what had caused this as all the images on the card/camera had remained intact the previous times I had put the card in the notebook (I'm constantly viewing images on the camera & usually go through all of them in passing daily). I had no idea what had caused this, and was afraid to put the card back into the notebook. After trying to explain this on some camera forums I needed to know the exact messages I received trying to view those images. Put the card in, took it out, and no more pictures were effected. A day passed and I figured I could work on filing pictures from the other months until I could solve the problem. I went through the camera first, and all the other images were fine. Put the card in and was presented with the "DETAILS" view again, so I changed it from that to "MEDIUM ICONS". MISTAKE. BIG MISTAKE. The same thing happened to several pictures from that file, which I immediately saw, closed the file, and took the card out. The images which had been fine moments before were now question marks on my camera. Genius that  I am had to do it twice to figure out what did it. After that I tried changing the view back to "DETAILS", which of course didn't work.Prior to that I didn't think it was the camera, but I wasn't sure if it was the card or the notebook. I've had the camera 3 years, no problem. I've had the card 6 months, no problem. I've only had the notebook a few weeks, and had only started using the card reader a few days before this happened. Any help would be greatly appreciated as most of the pictures effected were irreplacable Christmas pictures.
    Just in case it helps my camera is a Canon PowerShot SX150 IS and the card is Wintec filemate Professional Plus 64GB.

    Thank you for responding,
                                                          I have tried copying the affected images after they began to display the problem, but they opened (or rather didn't) the same as before I copied them.
    I was using the default program to view the pictures, HP Connected Photo. However after this occurred I attempted to view them with Windows Photo viewer, with the same result.
    Unfortunately I do not have an external card (but if i knew it would restore the photos I would definitely get one).
    I don't think I have a virus, and the notebook is still so new I have the trial of McAfee running (which, for what it's worth, says "Your computer is secure". My internet service is also protected.
    As stated I was copying images from the card for several days (and taking the card out & inserting it back into my camera after each use) with no altered images showing up either on the camera or the notebook. It wasn't until I changed the way I was viewing the files from details to thumbnails (medium icons) that some of the images from that file were affected. (The pictures had automatically been seperated into files by month, so there were 6 files. Only the file with the thumbnails I switched how I was viewing had altered images. The other 5 files remained fine, until I did the same with November's file, at which time some of those images became unviewable as well).

  • Will any change in tempdb database affect the user defined tables?

    Will any change in tempdb database affect the user defined tables?
    Suppose I have deleted a table from system database tempdb, will it effect the user defined tables?
    Anujit Karmakar Sr. Software Engineer

    The short answer is no; deleting a table from tempdb will not affect user databases.
    Of course I could make up some connection between the two that you haven't described. For example, if a stored procedure created a temporary table, and was busy using it when you deleted it, the deletion could cause unexpected behavior in the user database,
    which could affect some table data.
    Also, some system actions in user databases can store data in tempdb temporarily. But you aren't likely to be talking about system usages of tempdb.
    So, unless you describe some connection, the tables in tempdb are independent from the user database tables.
    Rick Byham, Microsoft, SQL Server Books Online, Implies no warranty

  • Change file from .tiff to .pdf?

    How do I change file from .tiff to .pdf? (I scanned in a large volume of items, and didn't realize they were not in.pdf).

    Select a file, CMD+I, and change the Open with selection. Select Change all.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

  • How to change the default search engine? I accidentaly change it from google to yahoo, and I can't get it back. I changed my homepage too, but it isn't solved. Thanks

    dear, there.
    how to change the default search engine? I accidentaly change it from google to yahoo, and I can't get it back. I changed my homepage to google too, but it isn't solved. Thanks

    Clarification:
    I believe now you potentially lose all extensions, plug-ins when you use the new reset function, but you will let me know.
    If that is the case, your find corrupt file method maybe better. However, I reviewed the two help articles and there appear to be more files than just the delete search.json file and a possible search.sqlite file in the Firefox Profile Folder. I am confused. Then I have to find the folders. I think help articles mentioned how to find the profile containing the files, but not sure.

  • I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?

  • How to import a Change request from One application to another application.

    Hi,
      In SRM Dev system I have created a Change request (Transport Request) and released to the QA system.The Change request has imported successfully to the SRM QA system.
    Now the Case is:
    The Released Request in the SRM Dev system has to be Export to the CRM Dev system.
    Is it possible to Export the Released Change Request from SRM system to CRM system?
    If possible then can you provide me with the solution.
    Thanks in Advance
    Dharma

    Hi,
    Your system admin knows how to do it. System admin should define transport route. Please check it in transaction STMS.
    Regards,
    Masa

  • What key(s) do i type to change language from english to other? i am writing s story in dual languages. i was told to click command and space bar together but it is not working.

    what key(s) do it type to change language from english to other? i am writing a story in dual languages. I was told to click command and space bar together but it is not working.

    Command Spacebar opens Spotlight as you have found out. If you want to change languages you need to say what app you are using to write the story in, I'm guessing you are using Pages or MS Word. If that's the case
    Pages: Open Inspector - Click the T tab - Click Language and change your language.
    MS Word: Tools Menu - Language - Choose your language.

  • I cannot change my username despite Itunes telling me I must change it from my aol username.  All support has told me is to log in and I will be cued to do so.  This doesnot happen.  This is my 4th attempt at help.

    Itunes sent email that said I had to change username from aol account.  I have logged out, logged in again and no cue to change this pops up.  I have attempted 3 different times to get help and each time, someone tells me to do the SAME EXACT THING THAT I HAVE DONE 20 TIMES AND HAD NO EFFECT.  The only thing that itunes allows me to do is change my password NOT MY USERNAME.

    Details of the upgrade process are at Convert your AOL Username to an Apple ID, however you only need to make this change if your AppleID is based on an AOL screen name rather than an email address that ends in say @aol.com or @aol.co.uk.
    The fact the you've tried signing out and in again without being promoted suggests your Apple ID is based on your email address and therefore nothing needs to be done.
    tt2

  • How/can I change the "from" address in Mail?

    I just upgraded to Mountain Lion, and have come across a problem.
    I use iCloud for my mail account, but I want to change the "from" address - so the return address on my messages is NOT icloud.
    I could do this in Lion.
    In the mail account settings, there's an option that says "alias" and it lists (me)@mac.com, (me)@me.com and (me)@icloud.com, and then "custom" is an option.
    Great!
    So I choose Custom, and then I can type in the "from" address that I want.
    However, when I go to save those changes, it tells me the SMTP server can't be left blank.
    What?
    It's not blank! I didn't touch it. The icloud server is still there!
    Furthermore, it's greyed out, so even if it WERE blank, it's not like I can edit it!
    Once this happens, the only fix is to delete the whole account from mail, and to disable mail in the icloud control panel, then re-add it.
    Has anyone figured out to work around this?

    Apple's outgoing mail server - just like 99.9% of all other SMTP servers, does not allow "relaying", meaning you use a domain in the 'sent from' address that is different from a domain hosted by the server. The simple reason is to make it harder for any spammer - not assuming you are one - to abuse the server. While bandwidth, server capacity and server load are some issues, the main fear for ISPs is to get blacklisted, and consequently mails from such server being refused by all others.
    It's a general rule, and while exceptions might be technically possible, it would be a manual act which at a certain rate would become unmanageable.
    If you want, read about the antonym, open mail relay servers, here.
    You see, it's actually good behavior and absolutely in your interest to prevent you from using a "non-in-house" 'sent from' address.

  • How do I change Itunes from one account to two in my home?

    how do I change Itunes from one account to two in my home?

    You don't.
    What are you trying to do?

  • On MacBook Pro, in iCloud cannot access Apple ID username to change it, from previous user. Can you help?

    On MacBook Pro, in iCloud I cannot access Apple ID username to change it, from previous user. Can anyone help?

    In System Preferences>iCloud: Sign Out, reboot and then Sign In with your ID and password.
    If Find My Mac is switched on you will be unable to sign out without the previous owners password.

  • Why can I not find the primary video setting in Bios so I can change it from integrated to PCIE?

    I have purchased a new video card to add to my computer which has integrated graphics.  When I installed the card I got a blank screen so I removed the card and restarted the computer and entered BIOS in an attempt to change it from integrated to PCIE the problem is I cannot find the option to make the change.  I can select advanced chipset but there is no primary video option to select and as far as I can tell there is no option to switch it from integrated to PCIE....  I researched this heavily and am now resorting to this as I cannot find a way to get the video card to work.  I have posted the options I have in my system's Bios below.  Thnks for looking   BIOS Version 2.14.1219Options:Main     Advanced      Power      Security      Boot Options       Exit Main:System infoDateTimeAdvancedMiscellaneous            AHCI Post 1 Not Present            AHCI Post 2 Not Present            AHCI Post 3 Not Present            AHCI Post 4 HL-DT-ST- DVDRAM GH7ON            AHCI Post 5 Not PresentAdvanced Chipset Configuration            Intel EIST             [Enabled]            Intel Turbo Boost [Enabled]            Intel AES-NI        [Disabled]            Intel XD BIT        [Enabled]            DVMT Mode        [DVMT]            DVMT Memory Size [256mb]Integrated Peripherals            Onboard SATA Controller [Enabled]            Onboard USB Controller [AHCI]            Legacy USB Support [Enabled]            USB Storage Emulation [Auto]            Onboard Audio Controller [Enabled]            Onboard LAN Controller [Enabled]            Onboard LAN Option ROM [Disabled]PC Health Status            {Health Status info}Smart Fan [Enabled]PowerACPI Suspend Mode   [3(STR)]Deep Power Off ModePower On By RTC AlarmPower on by PCIE AlarmPower on by Onboard LANWake up by PS2 Keyboard/MouseWake up by USB Keyboard/MouseRestore on AC Power LossSecuritySupervisor passwordUsername PasswordChange Supervisor PasswordBoot Options1st Boot Device2nd Boot Device3rd Boot Device4th Boot Device5th Boot DeviceEFI Device PriorityHard Disk Drive PriorityOptical Disk Drive PriorityRemovable Device PriorityNetwork Device PriorityQuiet Boot OnHalt OnExit    

    iPhone User Guide (For iOS 7 Software)Sep 20, 2013 - 23 MB

  • Creating a new subfolder in SENT and changing to/from menus

    How do i create a new subfolder in SENT ? (it works in all incoming folders but not in sent). Also is it possible to change the "from" menu heading to "to" in a mailfolder.

    Hello JB-Baby
    You can't create a subfolder in Sent. Mail does this automatically for each account you set up. If you wish to organise messages you send by some criteria or other, why not consider a Smart Mailbox?
    I assume by your second question you mean can you change the columns in the message viewer? Yes you can. You select View -> Columns and check the ones you want. You can adjust the order of the columns by dragging the titles around in the message viewer.
    If you didn't mean this, maybe you could explain what you are after in a little more detail.

Maybe you are looking for

  • How can we handle errorrecords in session and calltransaction methods

    hi experts can u help me for this

  • How to hide scroll bar

    Hi everyone, when i display iviews on the page it should not show me the scroll bar. how to hide the scroll bar in iview.

  • Cursor should be at Current checkbox

    Hi All, I have written the coding.If i check the record,and do some calculations affter click on Pre-Calculate Button again the cursor is going to 1st record. plss can any one help me in this issue.. In WHEN_BUTTON_PRESSED trigger i have written the

  • Bare structure of stored Proc

    Hi. I was wondering if someone could give me the bare neccesities of a stored proc. I'm trying to call one from java. What I have is: create or replace procedure proc1 as BEGIN END but I get compilation errors. Thanks you!

  • File not creating in AL11 wen executing in Background

    Hi, I have written code to upload some data to Appln server(AL11). When i execute in foreground, file is creating. But wen i execute in background, i couldnt find that file in the path which i have given. Since we cant debug the program in Background