문제

I have a XAML file what is more than 2k lines long. I'd like to refactor to manageable pieces.

In the resources section I have a converter what convert enum to DataTemplate:

        <UserControl.Resources>
            <converters:SomeConverter x:Key="EnumToDataTemplateConverter">
                <converters:SomeConverter.NumericBoxTemplate>
                    <DataTemplate>
                        ... long template description ...
                    </DataTemplate>
                </converters:SomeConverter.NumericBoxTemplate>
            </converters:SomeConverter x:Key="EnumToDataTemplateConverter">
        </UserControl.Resources>

I've refactored the DataTemplate to a ResourceDictionary with a x:Key="xyDataTemplate"

My question is how can I create it in the original place?

        <UserControl.Resources>

            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="XyTemplate.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>

            <converters:SomeConverter x:Key="EnumToDataTemplateConverter">
                <converters:SomeConverter.NumericBoxTemplate>
                    ???
                </converters:SomeConverter.NumericBoxTemplate>
            </converters:SomeConverter x:Key="EnumToDataTemplateConverter">
        </UserControl.Resources>
도움이 되었습니까?

해결책

It would help if we could see the declaration of the property in the converter, but for now try:

<converters:SomeConverter x:Key="EnumToDataTemplateConverter"
                          NumericBoxTemplate="{StaticResource xyDataTemplate}"/>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top