MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.32k stars 2.45k forks source link

Toggle Button style error #365

Closed FAlbanna closed 11 years ago

FAlbanna commented 11 years ago

I am using the toggleSwitchbutton with the style written in the project not using a dll and it works fine but if property IsChecked="True" then it gives the error:

'[Unknown]' property does not point to a DependencyObject in path '(0).(1)[3].(2)'

FAlbanna commented 11 years ago

error is that VS cannot iterate through the TargetProperty in this line:

<DoubleAnimation Duration="0:0:0.05" To="47" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="SwitchThumb">

Solved it by Changing it to:

<DoubleAnimation Duration="0:0:0.05" To="47" Storyboard.TargetProperty="(TranslateTransform.X)" Storyboard.TargetName="ThumbTranslate">

after giving the transformation a name

<TranslateTransform x:Name="ThumbTranslate"/>
shiftkey commented 11 years ago

Can you create a pull request for this fix so I can see it myself? I'm curious if the templates have changed as that should just work...

punker76 commented 11 years ago

@FAlbanna You say: "... not using a dll ..." Can you provide your style? Has you style this transform group (for SwitchThumb)?

<TransformGroup>
    <ScaleTransform/>
    <SkewTransform/>
    <RotateTransform/>
    <TranslateTransform/>
</TransformGroup>
FAlbanna commented 11 years ago

Yes everything was working correctly but but all the toggleswitches gave an error and froze the desgin view if given the property IsChecked="True".

I modified the original style to include the same changes I had to do here: https://github.com/MahApps/MahApps.Metro/pull/374

punker76 commented 11 years ago

@FAlbanna I got no error or frozen design if i set IsChecked="True" in Mahapp MetroDemo...

FAlbanna commented 11 years ago

Here is the error I got,

TSerror

Im not an expert on WPF so I can't explain it but that's how it went with me

Expection:

'[Unknown]' property does not point to a DependencyObject in path '(0).(1)[3].(2)'. at System.Windows.Media.Animation.Storyboard.VerifyPathIsAnimatable(PropertyPath path) at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer) at System.Windows.Media.Animation.Storyboard.ClockTreeWalkRecursive(Clock currentClock, DependencyObject containingObject, INameScope nameScope, DependencyObject parentObject, String parentObjectName, PropertyPath parentPropertyPath, HandoffBehavior handoffBehavior, HybridDictionary clockMappings, Int64 layer) at System.Windows.Media.Animation.Storyboard.BeginCommon(DependencyObject containingObject, INameScope nameScope, HandoffBehavior handoffBehavior, Boolean isControllable, Int64 layer) at System.Windows.VisualStateGroup.StartNewThenStopOld(FrameworkElement element, Storyboard[] newStoryboards) at System.Windows.VisualStateManager.GoToStateInternal(FrameworkElement control, FrameworkElement stateGroupsRoot, VisualStateGroup group, VisualState state, Boolean useTransitions) at System.Windows.VisualStateManager.GoToStateCommon(FrameworkElement control, FrameworkElement stateGroupsRoot, String stateName, Boolean useTransitions) at System.Windows.VisualStateManager.GoToState(FrameworkElement control, String stateName, Boolean useTransitions) at MahApps.Metro.Controls.ToggleSwitchButton.ChangeVisualState(Boolean useTransitions) at MahApps.Metro.Controls.ToggleSwitchButton.OnApplyTemplate() at System.Windows.FrameworkElement.ApplyTemplate() at Microsoft.Expression.Platform.WPF.WpfViewNodeManager.EnsureElementInDictionary(Object root, ViewNode knownAncestor)

shiftkey commented 11 years ago

@FAlbanna are you using the "bad" template (which has the issue)?

I've tested out #374 locally and I don't see the VS designer issue (and the animation works as expected at runtime).

shiftkey commented 11 years ago

I've merged in #374, please reopen if you still see the designer issue and can tell me which release you have installed.