question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with ui:ToggleSwitch in Tab

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
m1lcommented, Nov 18, 2020

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.

0reactions
m1lcommented, Mar 5, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toggle Buttons vs Tabs
What are the problems with using toggle buttons instead of of tabs? I have a design where action buttons and tabs share the...
Read more >
Cannot display switch in tabs in material-ui - reactjs
I need my tabs to have a tab consisting of a switch but when I implemented it as it was said, I am...
Read more >
Toggle switch problem
I have set up a light that is operated by a button that toggles the light on or off. It works okay but...
Read more >
Toggle-Switch Guidelines
On/off switches are UI elements that prompt users to choose between 2 mutually exclusive options, always have a default value, ...
Read more >
[SOLVED] Ribbon - toggle button problems
Hi guys, I'm not sure if this can be done, but I am trying to create two toggle buttons in a custom ribbon...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found