I have a user control. I had this situations again some times but could always fix it by using the "New()
contructor". But I still wonder what I am doing wrong because the load event has to be fired if control was loaded!
Here is some code:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:OUTPUT___VideoContent"
Title="OUTPUT - VideoContent" Height="350" Width="525" Icon="/OUTPUT%20-%20VideoContent;component/Images/VideoContent.png">
<Grid x:Name="LayoutRoot">
<Grid x:Name="VideoGrid">
<my:ucVideoPresenter x:Name="VideoPresenter1"/>
<TextBlock x:Name="txtInfo" Visibility="Collapsed" />
</Grid>
</Grid>
</Window>
and in the usercontrol, the load event is declared on WPF or codebehing without any success!
This is because an exception is being thrown in the 'Loaded' eventhandler. The exception may be occurring as a result of a mixed mode assembly or some other exception that is "user handled", and the WPF framework is catching it (unknown to the debugger). This causes the debugger not to break when a breakpoint is set within the Loaded method.
To make sure you can see exactly what error is occurring:
Does your UserControl constructor still make a call InitializeComponent()
, without this, it will not build up its visuals and the Loaded
event may not fire.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With