Skip to content

Commit

Permalink
Fix #99: Clicking a combobox results in NullReferenceException
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed May 24, 2020
1 parent 2e24f4a commit c470170
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ModernWpf.Controls/AutoSuggestBox/AutoSuggestBox.cs
Expand Up @@ -544,7 +544,7 @@ private bool IsPopupOpenDown()

private object ResourceLookup(object key)
{
return Resources.Contains(key) ? Resources[key] : Application.Current.TryFindResource(key);
return TryFindResource(key);
}

private TextBox m_textBox;
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf/Controls/Primitives/ComboBoxHelper.cs
Expand Up @@ -163,7 +163,7 @@ private static bool IsPopupOpenDown(ComboBox comboBox)

private static object ResourceLookup(Control control, object key)
{
return control.Resources.Contains(key) ? control.Resources[key] : Application.Current.TryFindResource(key);
return control.TryFindResource(key);
}

private static T GetTemplateChild<T>(string childName, Control control) where T : DependencyObject
Expand Down
20 changes: 16 additions & 4 deletions samples/PowerShellSample/MainWindow.xaml
Expand Up @@ -6,15 +6,22 @@
Title="PowerShell Sample"
Height="450"
Width="800"
Background="{DynamicResource SystemControlPageBackgroundChromeMediumLowBrush}"
ui:TitleBar.IsIconVisible="True">
Style="{DynamicResource PowerShellWindowStyle}">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ColorPaletteResources Accent="#FF0078D7" />
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/ThemeResources/Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/ControlsResources.xaml" />
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/ThemeResources/Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/ControlsResources.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="PowerShellWindowStyle" TargetType="Window">
<Setter Property="Foreground" Value="{DynamicResource SystemControlPageTextBaseHighBrush}" />
<Setter Property="Background" Value="{DynamicResource SystemControlPageBackgroundAltHighBrush}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="ui:ThemeManager.IsThemeAware" Value="True" />
</Style>
</ResourceDictionary>
</Window.Resources>
<ScrollViewer>
Expand All @@ -28,6 +35,11 @@
<Button
Content="I am an accent button"
Style="{StaticResource AccentButtonStyle}" />
<ComboBox>
<ComboBoxItem Content="List Item" IsSelected="True" />
<ComboBoxItem Content="List Item" />
<ComboBoxItem Content="List Item" />
</ComboBox>
</ui:SimpleStackPanel>
</ScrollViewer>
</Window>

0 comments on commit c470170

Please sign in to comment.