Skip to content

Exception thrown upon hovering / pressing a GridSplitter, when its background isn't a SolidColorBrush #2262

@ravindUwU

Description

@ravindUwU

I'm submitting a...

  • Bug report (I searched for similar issues and did not find one)

Current behavior

When the background of a GridSplitter is assigned to a Brush that isn't a SolidColorBrush, a COMException is thrown upon hovering it:

System.Runtime.InteropServices.COMException (0x800F1000): No installed components were detected.

Cannot resolve TargetProperty (Grid.Background).(SolidColorBrush.Color) on specified object.
    at Windows.UI.Xaml.VisualStateManager.GoToState(Control control, String stateName, Boolean useTransitions)
    at Microsoft.Toolkit.Uwp.UI.Controls.GridSplitter.GridSplitter_PointerEntered(Object sender, PointerRoutedEventArgs e)}

HResult -2146496512

Message "No installed components were detected. Cannot resolve TargetProperty (Grid.Background).(SolidColorBrush.Color) on specified object."

This occurs due to the "PointerOver" VisualState at: https://github.com/Microsoft/WindowsCommunityToolkit/blob/28577f08fc606a9d02bdc757f058de99c90c8aa7/Microsoft.Toolkit.Uwp.UI.Controls/GridSplitter/GridSplitter.xaml#L22-L37 where the background is assumed to be a SolidColorBrush, whose color is animated. The "Pressed" VisualState would presumably throw an analogous exception.

Expected behavior

The background of the GridSplitter changes to the specified Brush.

Minimal reproduction of the problem with instructions

<Page ...
    xmlns:toolkit="using:Microsoft.Toolkit.Uwp.UI.Controls">
<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <toolkit:GridSplitter Grid.Column="1" HorizontalAlignment="Left">
        <toolkit:GridSplitter.Background>
            <!-- Assign something other than a SolidColorBrush (e.g. LinearGradientBrush, ImageBrush, etc.) -->
            <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                <GradientStop Color="Black" />
                <GradientStop Offset="1" Color="White" />
            </LinearGradientBrush>
        </toolkit:GridSplitter.Background>
    </toolkit:GridSplitter>
</Grid>

Upon running the app and hovering over the GridSplitter, the app crashes with the exception detailed under "Current Behaviour".

Environment

Nuget Package(s):
    Microsoft.Toolkit.Uwp.UI.Controls

Package Version(s): 
    3.0.0

Windows 10 Build Number:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [x] April 2018 Update (17134)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [x] April 2018 Update (17134)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [x] 2017 (version: Community 2017 15.4.1)
- [ ] 2017 Preview (version: )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions