I have a small window that I am trying to load when my application starts. Here is the (loose) XAML:
<ctrl:MainWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctrl="clr-namespace:Controls;assembly=Controls">
<Grid>
<ctrl:ConnectionStatusIndicator/>
<TextBlock Grid.Row="2" Text="{Resx ResxName=MyApp.MainDialog, Key=MyLabel}"/>
</Grid>
</ctrl:MainWindow>
Notice the custom control called ConnectionStatusIndicator. The code for it is:
using System.Windows;
using System.Windows.Controls;
namespace Controls
{
public class ConnectionStatusIndicator : Control
{
public ConnectionStatusIndicator()
{
}
static ConnectionStatusIndicator()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ConnectionStatusIndicator),
new FrameworkPropertyMetadata(typeof(ConnectionStatusIndicator)));
IsConnectedProperty = DependencyProperty.Register("IsConnected", typeof(bool), typeof(ConnectionStatusIndicator), new FrameworkPropertyMetadata(false));
}
public bool IsConnected
{
set { SetValue(IsConnectedProperty, value); }
get { return (bool)GetValue(IsConnectedProperty); }
}
private static DependencyProperty IsConnectedProperty;
}
}
Now, here is where it gets weird (to me, at least). With the XAML as it appears above, my application will build and run just fine. However, if I remove the following line:
<ctrl:ConnectionStatusIndicator/>
or event move it one line down, I get the following error:
Additional information: 'Cannot create unknown type '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}Resx'.' Line number '13' and line position '33'.
What is really strange to me is that, if I replace ConnectionStatusIndicator with another custom control from the same assembly, I get the error. The other custom control is very similar, but has a few more properties.
Can anyone explain what is going on here?
{Resx ResxName=MyApp.MainDialog, Key=MyLabel}
? – Hamlet HakobyanIsConnectedProperty
public, see if it does anything to help. – Psytronic