locked
Problem with DataBinding after sharing

    Question

  • Hello everybody!

    I'm struggling with this problem a few days now and I hope you can help me.

    I have a XAML control (FrontEnd) with several dependency properties. This control uses another XAML control (PdfViewer).

    The PdfViewer holds a reference to the FrontEnd which gets initialized inside the constructor (the PdfViewer instance is always created in the code of the FrontEnd and added to the Children of a canvas)

    The PdfViewer holds several pdfPages with elements (e.g. TextBoxes or SignatureFields), the layout of those elements is decided with the help of a DataTemplateSelector for an ItemsControl.

    The templates have some Bindings to the Owner dependency property as you can see.

    Everything is working fine when launching the app normally. I can add elements to a page dynamically, the element gets recognized (its kept by an ObservableCollection), and the DataTemplate gets added to the view and displayed.

    Also, when the app was launched before (and its current state is suspended) and a file gets shared with my app and I open the "Main" window from the ShareView (I'm doing this using a protocol activation and from the share view I use "await Launcher.LaunchUriAsync(uriBuilder.Uri);" ) everything is working fine. I still can add elements to a page.

    The problem is, when the app has been shutdown and someone shares a file with my app, the sharing window still works fine. When opening the file out of the sharing window in the MainWindow (with the Uri launcher), the app still launches normally. But when I try to add another element to the page, I'll receive the following error:

    WinRT originate error (parameters: 0x802B000A, 0x00000064, 0x05A1D178).
    The text associated with this error code could not be found.
    Failed to assign to property 'Windows.UI.Xaml.Controls.Border.Background'. [Line: 124 Position: -99]

    When I try to change the Text property of a TextBlock I'll get this:

    First-chance exception at 0x049A7230 (Windows.UI.Xaml.dll) in SignatureCapture.exe: 0xC0000005: Access violation reading location 0x00000008.
    Unhandled exception at 0x049A7230 (Windows.UI.Xaml.dll) in SignatureCapture.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

    Here is a part of the PdfViewer.xaml (I didn't add all of the DataTemplates and Styles)

    <UserControl
        x:Class="PdfViewer"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:xamlHelpers="using:XamlHelpers"
        xmlns:components="using:Components"
        mc:Ignorable="d"
        d:DesignHeight="300"
        d:DesignWidth="400"
        x:Name="pdfControl"
        PointerReleased="PdfViewer_OnPointerReleased"
        PointerMoved="PdfViewer_OnPointerMoved"
        Loaded="PdfViewer_Loaded"
        SizeChanged="PdfViewer_SizeChanged"
        x:FieldModifier="internal"
        IsDoubleTapEnabled="False"
        IsHoldingEnabled="false">
    	
    	<UserControl.Resources>
    		<DataTemplate x:Key="dragableSignatureFieldTemplate">
    			<Border Tag="{Binding}"
    								PointerPressed="OnDragableSignatureFieldTemplatePointerPressed"
    								Width="{Binding Width}" Height="{Binding Height}"
    								BorderThickness="2"
    								Background="{Binding Owner.OptionalSignatureFieldBackgroundBrush, ElementName=pdfControl}"
    								BorderBrush="{Binding Owner.OptionalSignatureFieldBorderBrush, ElementName=pdfControl}"
    								Margin="{Binding Margin}"
    								ManipulationMode="None" IsDoubleTapEnabled="False"
    								IsHoldingEnabled="False" IsRightTapEnabled="False" MinWidth="120" MinHeight="120"
    								SizeChanged="SignatureFieldTemplateSizeChanged">
    				<Grid>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition Width="50" />
    						<ColumnDefinition Width="*" MinWidth="20" />
    						<ColumnDefinition Width="50" />
    					</Grid.ColumnDefinitions>
    					<Grid.RowDefinitions>
    						<RowDefinition Height="50" />
    						<RowDefinition Height="*" MinHeight="20" />
    						<RowDefinition Height="50" />
    					</Grid.RowDefinitions>
    					<Grid Grid.Row="0" Grid.Column="0" RowSpan="3" ColumnSpan="3"
    									  SizeChanged="SignatureFieldTextBoxSizeChanged">
    						<TextBlock Style="{StaticResource SignatureFieldTextBlockStyle}"
    											   Text="{Binding SignatureFieldText, ElementName=pdfControl}"
    											   Foreground="{Binding Owner.SignatureFieldLineAndTextColorBrush, ElementName=pdfControl}"
    											   FontSize="16"
    											   Margin="15, 35, 15, 35" />
    					</Grid>
    					<Grid Grid.Row="2" Grid.Column="0">
    						<SymbolIcon Symbol="Cancel" Style="{StaticResource SignatureFieldSymbolIconStyle}"
    												Foreground="{Binding Owner.SignatureFieldLineAndTextColorBrush, ElementName=pdfControl}"
    												Margin="0,0,0,10" HorizontalAlignment="Right" />
    					</Grid>
    					<Grid Grid.Row="2" Grid.Column="1">
    						<Line Style="{StaticResource SignatureFieldLineStyle}"
    										  Stroke="{Binding Owner.SignatureFieldLineAndTextColorBrush, ElementName=pdfControl}"
    										  Margin="0,0,0,10" />
    					</Grid>
    					<Border Grid.Column="2" Grid.Row="0"
    										BorderBrush="{Binding Owner.AdhocSignatureFieldButtonBorderBrush, ElementName=pdfControl}"
    										BorderThickness="1" Name="deleteBox">
    						<SymbolIcon Symbol="Clear" VerticalAlignment="Center" HorizontalAlignment="Center"
    												Foreground="{Binding Owner.SignatureFieldLineAndTextColorBrush, ElementName=pdfControl}" />
    					</Border>
    					<Border Grid.Column="2" Grid.Row="2"
    										BorderBrush="{Binding Owner.AdhocSignatureFieldButtonBorderBrush, ElementName=pdfControl}"
    										BorderThickness="1" Name="resizeBox">
    						<SymbolIcon Symbol="FullScreen" VerticalAlignment="Center"
    												HorizontalAlignment="Center"
    												Foreground="{Binding Owner.SignatureFieldLineAndTextColorBrush, ElementName=pdfControl}" />
    					</Border>
    				</Grid>
    			</Border>
    		</DataTemplate>
    
    		[....]
    		
    		<xamlHelpers:PdfElementSelector x:Key="pdfElementTemplateSelector" DragableSignatureFieldTemplate="{StaticResource dragableSignatureFieldTemplate}" />
    	</UserControl.Resources>
    
    	[....]
    	
    	<FlipView x:Name="documentVisualizationArea" x:FieldModifier="internal"
    			  Style="{StaticResource FlipViewNoButtonsStyle}" UseTouchAnimationsForAllNavigation="False" ItemsSource="{Binding}">
    		<FlipView.ItemTemplate>
    			<DataTemplate>
    				<!--<Canvas Background="Red" DoubleTapped="PageImage_DoubleTapped">-->
    				<Canvas Background="{Binding Brush}" DoubleTapped="PageImage_DoubleTapped"
    						Width="{Binding Width}" Height="{Binding Height}">
    					<ItemsControl ItemsSource="{Binding Elements}"
    								  ItemTemplateSelector="{StaticResource pdfElementTemplateSelector}">
    						<ItemsControl.ItemsPanel>
    							<ItemsPanelTemplate>
    								<Canvas />
    							</ItemsPanelTemplate>
    						</ItemsControl.ItemsPanel>
    					</ItemsControl>
    					<components:ProgressOverlay Width="{Binding ActualWidth, ElementName=scrollView}"
    												Height="{Binding ActualHeight, ElementName=scrollView}"
    												Visibility="{Binding Brush, Converter={StaticResource NullToVis}, ConverterParameter='invert'}"
    												HorizontalAlignment="Center" VerticalAlignment="Center"
    												HorizontalContentAlignment="Center"
    												VerticalContentAlignment="Center">
    						<components:ProgressOverlay.Background>
    							<SolidColorBrush Color="#77808080" />
    						</components:ProgressOverlay.Background>
    						<components:ProgressOverlay.Foreground>
    							<SolidColorBrush Color="White" />
    						</components:ProgressOverlay.Foreground>
    					</components:ProgressOverlay>
    				</Canvas>
    			</DataTemplate>
    		</FlipView.ItemTemplate>
    	</FlipView>
    </UserControl>

    Thank you!

    Best Regards,

    Daniel

    Thursday, July 10, 2014 1:55 PM

All replies

  • Hi Daniel,

    Could you directly share a reproducible demo with us for a better understanding and we can also test for it to see if there is a workaround or it is a known issue. You may share the package with us by OneDrive.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, July 14, 2014 7:36 AM
    Moderator