Skip to content

Commit fa28590

Browse files
Fix Binding errors when Ribbon is outside of RibbonWindow
This ensures that the Ribbon is hosted in a RibbonWindow before binding to the parent RibbonWidow, otherwise the Bindings may fail. Fixes #11860
1 parent 1cfc37f commit fa28590

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Themes/Generic.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2841,13 +2841,13 @@ To automatically copy the files, set the environment variable
28412841
</Trigger>
28422842
<MultiDataTrigger>
28432843
<MultiDataTrigger.Conditions>
2844-
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
28452844

28462845
<Condition Binding="{Binding Path=(SystemParameters.IsGlassEnabled)}" Value="False"/>
28472846

28482847

28492848

28502849
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
2850+
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
28512851
</MultiDataTrigger.Conditions>
28522852
<Setter TargetName="PART_TitleHost" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveCaptionTextBrushKey}}" />
28532853
</MultiDataTrigger>
@@ -2900,6 +2900,7 @@ To automatically copy the files, set the environment variable
29002900

29012901

29022902

2903+
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
29032904
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=WindowState}" Value="Maximized"/>
29042905
</MultiDataTrigger.Conditions>
29052906
<Setter TargetName="QatTopHost" Property="Margin" Value="0"/>

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Themes/Generic.xaml.sdk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2717,13 +2717,13 @@ Theme Styles For Windows Presentation Foundation Version 
27172717
</Trigger>
27182718
<MultiDataTrigger>
27192719
<MultiDataTrigger.Conditions>
2720-
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
27212720

27222721
<Condition Binding="{Binding Path=(SystemParameters.IsGlassEnabled)}" Value="False"/>
27232722

27242723

27252724

27262725
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
2726+
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
27272727
</MultiDataTrigger.Conditions>
27282728
<Setter TargetName="PART_TitleHost" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveCaptionTextBrushKey}}" />
27292729
</MultiDataTrigger>
@@ -2775,6 +2775,7 @@ Theme Styles For Windows Presentation Foundation Version 
27752775

27762776

27772777

2778+
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
27782779
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=WindowState}" Value="Maximized"/>
27792780
</MultiDataTrigger.Conditions>
27802781
<Setter TargetName="QatTopHost" Property="Margin" Value="0"/>

src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Themes/XAML/Ribbon.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,13 @@
327327
</Trigger>
328328
<MultiDataTrigger>
329329
<MultiDataTrigger.Conditions>
330-
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
331330
#ifdef Net45
332331
<Condition Binding="{Binding Path=(SystemParameters.IsGlassEnabled)}" Value="False"/>
333332
#else
334333
<Condition Binding="{Binding Path=IsGlassEnabled, Source={x:Static windows:SystemParameters2.Current}}" Value="False"/>
335334
#endif
336335
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
336+
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=IsActive}" Value="False"/>
337337
</MultiDataTrigger.Conditions>
338338
<Setter TargetName="PART_TitleHost" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveCaptionTextBrushKey}}" />
339339
</MultiDataTrigger>
@@ -386,6 +386,7 @@
386386
#else
387387
<Condition Binding="{Binding Path=UxThemeName, Source={x:Static windows:SystemParameters2.Current}}" Value="Aero"/>
388388
#endif
389+
<Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsHostedInRibbonWindow}" Value="True" />
389390
<Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ribbon:RibbonWindow}, Path=WindowState}" Value="Maximized"/>
390391
</MultiDataTrigger.Conditions>
391392
<Setter TargetName="QatTopHost" Property="Margin" Value="0"/>

0 commit comments

Comments
 (0)