응용 프로그램을 시작할 때로드하려고하는 작은 창이 있습니다.마크 업 확장 프로그램을 사용하려고 할 때 오류가 발생했습니다.
<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>
공지 사항 ConnectionStatusIndicator라는 사용자 지정 컨트롤 : 여기에 (느슨한) XAML입니다. 그 코드는 다음과 같습니다 :
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;
}
}
자, 여기가 이상하게 들립니다 (적어도 나에게). 위에 표시된 XAML을 사용하면 응용 프로그램이 제대로 빌드되고 실행됩니다. 나는 다음 줄을 제거하는 경우에는 : 나에게 정말 이상한 무엇
Additional information: 'Cannot create unknown type '{ http://schemas.microsoft.com/winfx/2006/xaml/presentation }Resx'.' Line number '13' and line position '33'.
내가 ConnectionStatusIndicator을 교체하는 경우이다 :
<ctrl:ConnectionStatusIndicator/>
이
또는 이벤트가 한 줄 아래로 이동, 나는 다음과 같은 오류가 발생합니다 동일한 어셈블리의 다른 사용자 정의 컨트롤을 사용하면 오류가 발생합니다. 다른 사용자 정의 컨트롤은 매우 비슷하지만 몇 가지 속성이 더 있습니다.
아무도 여기서 무슨 일이 일어날 지 설명 할 수 있습니까?
야해 네임 스페이스가 될 : CNC.UI.Controls는 XAML에서? – CSharpie
이 '{Resx ResxName = MyApp.MainDialog, Key = MyLabel}'이란 무엇입니까? –
내가 전에 물어 봤던 것 중 하나는 디자이너가 의존성 속성이 공개되지 않은 경우에 행동하기를 좋아한다는 것입니다. 'IsConnectedProperty'를 public으로 표시해보십시오. 도움이되는지 확인하십시오. – Psytronic