Issue with ui:ToggleSwitch in Tab
Got reports from several users that my program using ModernWPF cannot switch to tabs that have ui:ToggleSwitch. One of those tabs only has this:
<ui:ToggleSwitch
IsOn="{Binding Source={x:Static p:Settings.Default}, Path=EnableAnimations, Mode=TwoWay}"
OffContent="{DynamicResource TXT_EnableAnimations}"
OnContent="{DynamicResource TXT_EnableAnimations}" />
Using NuGet package 0.9.3-Preview.201004.0
Program is not Open Source but if you think it might be helpful, the compiled exe is at http://onecommander.com/v3.html and tabs in question are in Settings (gear icon bottom-left).
I can reproduce it by opening program, Win+L, unlock Windows, Win+L, unlock Windows, open settings
Sorry for interrupting you 😅.
Aren't you @milos12345?
You filed a similar issue in this repo, right?
P.S. I love your OneCommander app!
I remember seeing info about the app on the Windows 10 subreddit and Twitter. But I didn't know you were the developer. Thanks for making such a great app!
Yes, I am moving to this account, and I opened another issue in case it is a different cause although reproduced in the same way. Thanks for the kind words and happy to hear about it "in the wild"! Of course, the best of it is made possible by this great project.
I have replaced TabControl with the custom Style and that has fixed the rendering issue for the setting window, but this issue is new as I couldn't have noticed it before when the whole window was blank. I didn't notice anything common between those two in the Style, but whatever is causing this is definitely not there in Checkbox, TextBox, Dropdown and Slider controls as tabs containing those still work.
I can reproduce this one. Will investigate tomorrow. The app looks wonderful!
Is there any exception thrown when switching to the problematic tab?
@Kinnara Thank you! There is no exception that the program catches; just doesn't switch to the tab. In the latest version I have just left the "Test" tab with a switch (replaced all others with checkboxes). It is just inaccessible. But, if I make that tab a default when window is opened, then if I do the Lock-twice thing and try to open the settings dialog, it will result in blank windows just like the https://github.com/Kinnara/ModernWpf/issues/177
I might have found a related issue that also happens when locking the PC. When a window contains ComboBox I can open the ComboBox several times without issues, until I lock Windows and unlock it. Then the popup will not open again (the window is not blank like before though).
I see the [PopupRoot] in VS Live Visual Tree, but it is not visible on my window
I have "fixed" it by Right-Click, Edit a template copy and in that template commented out part of the code for ThemeShadowChrome :
<Popup x:Name="PART_Popup" AllowsTransparency="True" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="None" Placement="Bottom">
<Popup.PlacementRectangle>
<MultiBinding UpdateSourceTrigger="Default">
<MultiBinding.Converter>
<ui:PlacementRectangleConverter Margin="0,1"/>
</MultiBinding.Converter>
<Binding ElementName="Background" Path="ActualWidth"/>
<Binding ElementName="Background" Path="ActualHeight"/>
</MultiBinding>
</Popup.PlacementRectangle>
<!--<ui:ThemeShadowChrome x:Name="Shdw" CornerRadius="{Binding CornerRadius, ElementName=PopupBorder}" IsShadowEnabled="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" MaxHeight="{TemplateBinding MaxDropDownHeight}" Margin="28.8,28.8,28.8,41.6" MinWidth="{Binding ActualWidth, ElementName=LayoutRoot}">
<ui:OpeningAnimationHelper.Storyboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Shdw">
<DiscreteDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeySpline="0.1,0.9,0.2,1" KeyTime="0:0:0.383" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ui:OpeningAnimationHelper.Storyboard>-->
<Border x:Name="PopupBorder" Background="{DynamicResource ComboBoxDropDownBackground}" CornerRadius="{DynamicResource OverlayCornerRadius}" HorizontalAlignment="Stretch">
<Border BorderBrush="{DynamicResource ComboBoxDropDownBorderBrush}" BorderThickness="{DynamicResource ComboBoxDropdownBorderThickness}" CornerRadius="{Binding CornerRadius, ElementName=PopupBorder}" Padding="{DynamicResource ComboBoxDropdownBorderPadding}">
<ScrollViewer x:Name="ScrollViewer" Foreground="{DynamicResource ComboBoxDropDownForeground}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" Margin="{DynamicResource ComboBoxDropdownContentMargin}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
</Border>
<!--</ui:ThemeShadowChrome>-->
</Popup>
and also the related part above it in LayoutRoot
<Grid x:Name="LayoutRoot" SnapsToDevicePixels="True">
<!--<Grid.Resources>
<Storyboard x:Key="OverlayOpeningAnimation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Shdw">
<DiscreteDoubleKeyFrame KeyTime="0" Value="0"/>
<SplineDoubleKeyFrame KeySpline="0.1,0.9,0.2,1" KeyTime="0:0:0.383" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>-->
The storyboards are not causing the issue, and the issue still happens if I just leave
<ui:ThemeShadowChrome x:Name="Shdw" MaxHeight="{TemplateBinding MaxDropDownHeight}" Margin="28.8,28.8,28.8,41.6" MinWidth="100">
so in this case it looks to be something with ThemeShadowChrome