fluentribbon / Fluent.Ribbon

WPF Ribbon control like in Office
http://fluentribbon.github.io
MIT License
2.56k stars 518 forks source link

Changing theme from backstage is broken #263

Closed maurosampietro closed 8 years ago

maurosampietro commented 8 years ago

Themes are not applied correctly if you change it from the backstage. In particular if you use non Fluent controls that don't close the backstage/ribbon when clicked. The problem do not show up with Office 2013 style.

In the showcase if you add this tabItems you can test what i say:

<Fluent:BackstageTabItem Header="Change theme with fluent controls"
                        Content="Hello">
    <Fluent:BackstageTabItem.ContentTemplate>
        <DataTemplate>
            <StackPanel>           
                <Fluent:Button Background="Blue" Foreground="Black" Click="OnOffice2010SilverClick">Office 2010 Silver</Fluent:Button>
                <Fluent:Button Background="Blue" Foreground="Black" Click="OnOffice2010BlackClick">Office 2010 Black</Fluent:Button>
                <Fluent:Button Background="Blue" Foreground="Black" Click="OnOffice2010BlueClick">Office 2010 Blue</Fluent:Button>
                <Fluent:Button Background="Blue" Foreground="Black" Click="OnOffice2013Click">Office 2013 White</Fluent:Button>
                <Fluent:Button Background="Blue" Foreground="Black" Click="OnWindows8Click">Windows8 White</Fluent:Button>
            </StackPanel>
        </DataTemplate>
    </Fluent:BackstageTabItem.ContentTemplate>
</Fluent:BackstageTabItem>

 <Fluent:BackstageTabItem Header="Change theme with standard controls" Content="Hello">
        <Fluent:BackstageTabItem.ContentTemplate>
            <DataTemplate>
                <StackPanel>
                    <Button Click="OnOffice2010SilverClick">Office 2010 Silver</Button>
                    <Button Click="OnOffice2010BlackClick">Office 2010 Black</Button>
                    <Button Click="OnOffice2010BlueClick">Office 2010 Blue</Button>
                    <Button Click="OnOffice2013Click">Office 2013 White</Button>
                    <Button Click="OnWindows8Click">Windows8 White</Button>
                </StackPanel>
            </DataTemplate>
        </Fluent:BackstageTabItem.ContentTemplate>
    </Fluent:BackstageTabItem>
batzen commented 8 years ago

I still consider this a bug in WPF, but I found a workaround.

The reason why this issue occurs is because WPF does not find the ancestor of type Fluent:Backstage anymore. The funny/sad thing is with this code:

<Condition Binding="{Binding IsOpen, RelativeSource={RelativeSource AncestorType={x:Type Fluent:Backstage}}}" Value="True" />
<Condition Binding="{Binding IsOpenAnimationEnabled, RelativeSource={RelativeSource AncestorType={x:Type Fluent:Backstage}}}" Value="True" />

Guess what happens here... The first condition throws no binding error. The second one does, because the ancestor could not be found.