0
다른 어셈블리에서 사용자 지정 변환기를 구현하려고하지만 무시되고있는 것처럼 보입니다. 나는이 문제를 극복하고 내 오류를 볼 수 없으므로 일부 XAML 닌자가 도와 줄 수 있습니다. 여기에 관련 코드 ...다른 어셈블리의 사용자 지정 변환기 포함
xmlns:converters="clr-namespace:Shared.Converters;assembly=Shared"
그리고 리소스 사전 ... 여기
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Shared;component/Styles.xaml"/>
<ResourceDictionary>
<converters:SaveStatusConverter x:Key="saveStateConverter" />
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
은 전체 컨버터 자체이다.
네임 스페이스 Shared.Converters { 공용 클래스 SaveStatusConverter : IValueConverter 는 {
public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool? buttonState = (bool?)value;
Uri resourceLocater = new Uri("/Shared;component/Styles.xaml", System.UriKind.Relative);
ResourceDictionary resourceDictionary = (ResourceDictionary)Application.LoadComponent(resourceLocater);
if(buttonState == true)
return resourceDictionary["GreenDot"] as Style;
if (buttonState == false)
return resourceDictionary["RedDot"] as Style;
return resourceDictionary["GreyDot"] as Style;
}
public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new System.NotImplementedException();
}
} }
그리고 여기가
<ContentControl Style="{Binding Path=SaveState, Converter={StaticResource saveStateConverter}}"/>
내가 알고 ... 내 구현 스타일이 작동합니다 ... 문제가되지 않습니다, 나는 변환기라고 생각합니다. 괜찮아요. 문제를 볼 수는 없지만 전화하려고하는 방식과 관련이 있습니다.
미리 감사드립니다.