Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: NullReferenceException trying to use Zoombox [22079]

$
0
0
Not sure why I'm getting this exception trying to use the Zoombox control. It is throwing the NullReferenceException because the parent grid is Colapsed.


System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Xceed.Wpf.Toolkit
StackTrace:
at Xceed.Wpf.Toolkit.Zoombox.Zoombox.SetScrollBars()
at Xceed.Wpf.Toolkit.Zoombox.Zoombox.Zoombox_Loaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
InnerException:
Comments: ** Comment from web user: djryan7 **

The source code is:

<Window x:Class="MagnifyingAdornerSample.MainWindow"
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:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:dc="clr-namespace:WPF.JoshSmith.Controls"
xmlns:local="clr-namespace:MagnifyingAdornerSample"
mc:Ignorable="d"
Title="MainWindow"
MinHeight="600"
MinWidth="800"
Height="{Binding Source={x:Static SystemParameters.FullPrimaryScreenHeight}}"
Width="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}"
WindowStartupLocation="CenterScreen" >

<Window.Resources>

<Storyboard x:Key="MarchingAnts">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Storyboard.TargetName="selectionRectangle"
Storyboard.TargetProperty="(Shape.StrokeDashOffset)"
RepeatBehavior="Forever">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>

</Window.Resources>

<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource MarchingAnts}"/>
</EventTrigger>
</Window.Triggers>


<Grid
x:Name="findPlateView"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="9*" />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>

<xctk:Zoombox x:Name="imgZoomBox" MinScale="0.5" MaxScale="125" Style="{StaticResource myzoom}">
<Grid Width="{Binding Source={x:Static SystemParameters.FullPrimaryScreenWidth}}" Height="{Binding Source={x:Static SystemParameters.FullPrimaryScreenHeight}}" Background="Transparent">
<!-- Image with DragCanvas -->
<!-- The Drag Canvas is stretched to fill its content therefore by sizing it to match the image in code the selection box gets clipped to image size -->
<Image
x:Name="findPlateImage" Source="/Shared/sample.jpg"
Margin="5" SizeChanged="findPlateImage_SizeChanged"/>

<dc:DragCanvas x:Name="BackPanel" SizeChanged="BackPanel_SizeChanged" Background="Transparent" Visibility="Visible">
<Rectangle x:Name="selectionRectangle" Width="250" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center">
<Rectangle.Style>
<Style TargetType="{x:Type Rectangle}">
<Setter Property="Stroke" Value="#FFFFFF"/>
<Setter Property="StrokeDashArray" Value="5"/>
<Setter Property="StrokeDashOffset" Value="0"/>
<Setter Property="StrokeThickness" Value="3"/>
<Setter Property="Fill" Value="#14FFFFFF" />
<!-- <Setter Property="Fill" Value="Yellow"/>
<Setter Property="Opacity" Value="0.2"/> -->
</Style>
</Rectangle.Style>
</Rectangle>
</dc:DragCanvas>


</Grid>
</xctk:Zoombox>

</Grid>
</Window>


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>