Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding errors when using ComboBox #18

Closed
nkristek opened this issue Apr 5, 2019 · 3 comments
Closed

Binding errors when using ComboBox #18

nkristek opened this issue Apr 5, 2019 · 3 comments
Labels
question Further information is requested

Comments

@nkristek
Copy link
Collaborator

nkristek commented Apr 5, 2019

I noticed, that the application output is filled with messages, that a BindingExpression path error occured, when using a ComboBox:

System.Windows.Data Error: 40 : BindingExpression path error: '(adonisExtensions:WatermarkExtension.IsWatermarkVisible)' property not found on 'object' ''ComboBox' (Name='')'. BindingExpression:Path=(adonisExtensions:WatermarkExtension.IsWatermarkVisible); DataItem='ComboBox' (Name=''); target element is 'TextBox' (Name='PART_EditableTextBox'); target property is 'NoTarget' (type 'Object')
Exception thrown: 'MS.Internal.Xaml.Parser.GenericTypeNameParser.TypeNameParserException' in System.Xaml.dll
System.Windows.Data Error: 40 : BindingExpression path error: '(adonisExtensions:WatermarkExtension.Watermark)' property not found on 'object' ''ComboBox' (Name='')'. BindingExpression:Path=(adonisExtensions:WatermarkExtension.Watermark); DataItem='ComboBox' (Name=''); target element is 'ContentPresenter' (Name='PlaceholderHost'); target property is 'Content' (type 'Object')
Exception thrown: 'MS.Internal.Xaml.Parser.GenericTypeNameParser.TypeNameParserException' in System.Xaml.dll

These two errors occur for every ComboBox in my view.
I'm using the latest version of AdonisUI (1.9), I haven't noticed this with earlier versions but I have not tested it specifically with other versions of AdonisUI.
This is the view, the error occurs, the following code snippet is the ComboBox in the view:

<ComboBox Grid.Column="0"
          ItemsSource="{Binding InstallerBundles}"
          SelectedItem="{Binding SelectedInstallerBundle}"
          HorizontalContentAlignment="Stretch"
          ScrollViewer.CanContentScroll="True"
          VirtualizingStackPanel.IsVirtualizing="True"
          VirtualizingStackPanel.VirtualizationMode="Recycling"
          VirtualizingStackPanel.ScrollUnit="Pixel">

    <ComboBox.ItemsPanel>
        <ItemsPanelTemplate >
            <VirtualizingStackPanel/>
        </ItemsPanelTemplate>
    </ComboBox.ItemsPanel>
</ComboBox>

The view for an installer bundle consists of only a single TextBox:

<TextBlock TextTrimming="CharacterEllipsis"
           Text="{Binding Name}"/>

There seems to be no error while using the application, I just wanted to check, if the errors can be ignored.

@nkristek nkristek added the question Further information is requested label Apr 5, 2019
@benruehl
Copy link
Owner

benruehl commented Apr 7, 2019

I cannot reproduce this behavior with ComboBoxes but I get similar output for TabControls.

I found this blog post stating that they are harmless and handled internally. It seems the error can occur for all controls that contain dynamically created lists.

To resolve the binding errors you could try to explicitly set the watermark to {x:Null} or an empty string. As I cannot reproduce it, I cannot test that for you.
Alternatively you can change the log level globally as shown here.

@benruehl benruehl closed this as completed Apr 7, 2019
@benruehl
Copy link
Owner

benruehl commented Apr 7, 2019

Oh wait I just noticed that you received BindingError 40 and I get BindingError 4. My answer was supposed to target BindingError 4. I will do some research again but as I cannot reproduce it, it will be hard to tackle.

@benruehl
Copy link
Owner

I created a small application where I tried to recreate your setup and finally got the errors as well.

Writing

<DataTrigger Binding="{Binding Path=(adonisExtensions:WatermarkExtension.IsWatermarkVisible)}"/>

instead of

<DataTrigger Binding="{Binding (adonisExtensions:WatermarkExtension.IsWatermarkVisible)}"/>

fixed it for me.

Please reopen in case the errors are still present in your application.

benruehl added a commit that referenced this issue Apr 11, 2020
Add the `Path` keyword explicitly to template bindings that target
attached properties because the missing keyword lead to bugs
in the past. See #18 and #66 for reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants