10

I am getting the following:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

when the ListView attribute is set to Null in the Visual State. It makes no sense, why does VS and Blend complain?

<VisualState.Setters>
     <Setter Target="listView.(Selector.IsSynchronizedWithCurrentItem)" Value="{x:Null}"/>
</VisualState.Setters>

EDIT
A similar issue:

 <VisualState.Setters>
   <Setter Target="NumberButtonBox.(RelativePanel.RightOf)" Value="{x:Null}" />
   <Setter Target="NumberButtonBox.(RelativePanel.Below)" Value="GridPlaceholder" />
</VisualState.Setters>

where NumberButtonBox is defined as

<Viewbox x:Name="NumberButtonBox" RelativePanel.RightOf="GridPlaceholder" MaxWidth="250" MaxHeight="450" MinWidth="200">

The error shows only on the setter using a value of {x:Null}, not on the other line. Changing the order of the Setter lines has no effect.

Is setting the property to Null in this way the correct way to clear this value? At runtime it does work, just the editor has issues with this.

Hans Kesting
  • 34,565
  • 7
  • 74
  • 97
phm
  • 1,090
  • 1
  • 17
  • 29

1 Answers1

2

The only alternative to set null without crash at design time is this (as reported in this similar question)

example:

<Style x:Key="MyList" TargetType="ListView">
    <Setter Property="Transitions" >
        <Setter.Value>
            <TransitionCollection></TransitionCollection>
        </Setter.Value>
    </Setter>
</Style>

instead of:

Style x:Key="MyList"
        TargetType="ListView">
    <Setter Property="Transitions" 
            Value="{x:Null}"/>
</Style>
Community
  • 1
  • 1
Frix33
  • 1,191
  • 11
  • 27
  • An empty collection could work for a collection-type property, but not for others. And note that it is only the designer that reports a crash, runtime it works as expected. – Hans Kesting Jun 29 '16 at 18:31
  • Mmh for not collection-type i think the only way is use a Converter instead of x:Null bind. Check this: http://stackoverflow.com/questions/356194/datatrigger-where-value-is-not-null – Frix33 Jun 30 '16 at 06:31