2
votes

I have a problem with a WPF application. Somehow it seems that two (out of several) bindings in my WPF control are not immediately applied. When I look into the visual tree with Snoop, the binding is suddenly applied and everything works fine.

What can be the reason for that?

The XAML code is here:

<Grid Grid.Column="1" Margin="5">
    <m:Map ZoomLevel="12" Center="{Binding MapCenter, Mode=TwoWay}">
        <m:Map.CredentialsProvider>
            <m:ApplicationIdCredentialsProvider ApplicationId="???"/>
        </m:Map.CredentialsProvider>

        <m:Pushpin Location="{Binding Station.Location, Mode=TwoWay, Converter={StaticResource debugConverter}}" />
    </m:Map>
    <Button Command="{Binding CenterOnAddressCommand, PresentationTraceSources.TraceLevel=High, Converter={StaticResource debugConverter}}"
        Content="Adresse zentrieren" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,20" />
</Grid>

The binding of the Map.Center property works and the other two bindings (on Pushpin and Button) don't. The Map control is from the Bing Maps WPF Control.

EDIT: After some further investigation I tried removing the binding to the Map.Center property and then everything works (well except centering the map on a certain position). How can this be?

Thanks in advance!

2
The converters don't even get called?paparazzo
Exactly, they get called when I look at the binding in Snoop but not before that :(.chrischu
Not that I know what to do with this information but if you give it a bad binding name does PresentationTraceSources give you an error?paparazzo
No it doesn't change anything if I bind to some non-existing property :(.chrischu
Could it happen that the map control is invisible when you open the window? If so, it might not get templated before made visible, while touching it with Snoop might trigger initialization.Pavel Gatilov

2 Answers

2
votes

Two tips:

  1. Try upping the verbosity of the WPF messages displayed in the Output window. You can do this by going to Tools > Options > Debugging > Output Window > WPF Trace Settings and changing Data Binding to something like All.

  2. Add an UpdateSourceTrigger attribute to the bindings that are failing - it may be that the bindings aren't being told to update. Maybe Snoop triggers application-wide binding updates.

I hope that helps you find the cause of your problem.

0
votes

What about the m:Map control? Is that honoring the values when it is being initialized? ie if you give a fixed value for property is that working.

Try Reflector to verify the code of the Map control.