0

WPFテンプレートがありますが、アプリケーションの起動時に表示されません。WPFにエラーはなく、どこにもエラーはありません。テンプレートを使用しないでください。問題が何であるかを理解する方法は?

<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="MoveThumb.xaml"/>
    <ResourceDictionary Source="ResizeDecorator.xaml"/>
    <ResourceDictionary Source="RotateDecorator.xaml"/>
</ResourceDictionary.MergedDictionaries>

<!-- ContentControl style to move, resize and rotate items -->
<Style x:Key="DesignerItemStyle" TargetType="ContentControl">
    <Setter Property="MinHeight" Value="50"/>
    <Setter Property="MinWidth" Value="50"/>
    <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ContentControl">
                <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                    <Control Name="RotateDecorator"
                 Template="{StaticResource RotateDecoratorTemplate}"
                 Visibility="Collapsed"/>
                    <s:MoveThumb Template="{StaticResource MoveThumbTemplate}"
                     Cursor="SizeAll"/>
                    <Control x:Name="ResizeDecorator"
                 Template="{StaticResource ResizeDecoratorTemplate}"
                 Visibility="Collapsed"/>
                    <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="Selector.IsSelected" Value="True">
                        <Setter TargetName="ResizeDecorator" Property="Visibility" Value="Visible"/>
                        <Setter TargetName="RotateDecorator" Property="Visibility" Value="Visible"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<!-- RotateDecorator Template -->
<ControlTemplate x:Key="RotateDecoratorTemplate" TargetType="Control">
    <Grid>
        <my:RotateThumb Margin="-18,-18,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
        <my:RotateThumb Margin="0,-18,-18,0" VerticalAlignment="Top" HorizontalAlignment="Right">
            <my:RotateThumb.RenderTransform>
                <RotateTransform Angle="90" />
            </my:RotateThumb.RenderTransform>
        </my:RotateThumb>
        <my:RotateThumb Margin="0,0,-18,-18" VerticalAlignment="Bottom" HorizontalAlignment="Right">
            <my:RotateThumb.RenderTransform>
                <RotateTransform Angle="180" />
            </my:RotateThumb.RenderTransform>
        </my:RotateThumb>
        <my:RotateThumb Margin="-18,0,0,-18" VerticalAlignment="Bottom" HorizontalAlignment="Left">
            <my:RotateThumb.RenderTransform>
                <RotateTransform Angle="270" />
            </my:RotateThumb.RenderTransform>
        </my:RotateThumb>
    </Grid>
</ControlTemplate>

4

1 に答える 1

1

辞書とテンプレートを並べ替えて、機能するかどうかを確認してください。

同じ UIElement をターゲットにしていなくても、最後のディクショナリは常に以前のディクショナリ (テンプレート) をオーバーライドするため、 ORDERがすべてです。

于 2012-12-21T17:13:32.410 に答える