0

「PControls」という名前の別のライブラリに書き込まれているCostumControlの画像に関して問題があります。

そのライブラリ内に、画像「group.png」、「filter.png」、「sort.png」を含む「Resources」という名前のフォルダがあります。別のプロジェクトでコントロールを使用しようとすると、画像が表示されません...

私はすでに次のことを試しました:

  • すべてのイメージのビルド操作は、(埋め込みリソースではなく)リソースに設定されます

  • 画像ソース-可能なすべてのURIに設定されたプロパティ(例: "/ PControl; /component/Resources/filter.png") "../Resources/filter.png"は、VSが画像を検出しないように見える唯一の値です。表示されるエラー

これが私のスタイルの一部です。これは基本的に標準のWPFDataGridのスタイルであり、画像を表示するボタンを含むツールバーによって拡張されています。

<Style TargetType="{x:Type local:PDataGrid}">
    <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="BorderBrush" Value="#FF688CAF"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="RowDetailsVisibilityMode" Value="VisibleWhenSelected"/>
    <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
    <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
    <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:PDataGrid}">
                <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
                    <ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
                        <ScrollViewer.Template>
                            <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="25"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>

                                    <Button Command="{x:Static local:PDataGrid.SelectAllCommand}" Focusable="false" Style="{DynamicResource {ComponentResourceKey ResourceId=DataGridSelectAllButtonStyle, TypeInTargetAssembly={x:Type local:PDataGrid}}}" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.All}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type local:PDataGrid}}}" Width="{Binding CellsPanelHorizontalOffset, RelativeSource={RelativeSource AncestorType={x:Type local:PDataGrid}}}"/>
                                    <DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Grid.ColumnSpan="2" Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type local:PDataGrid}}}"/>
                                    <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="2" Grid.Row="1"/>

                                    <ToolBarTray Orientation="Vertical" Grid.Row="1" Grid.Column="2" IsLocked="True">
                                        <ToolBar Band="1" BandIndex="1" >
                                            <Button Width="24" Height="24" ToolTip="Sort">
                                                <Image Source="../Resources/sort.png" />
                                            </Button>
                                            <Button Width="24" Height="24" ToolTip="Filter">
                                                <Image Source="../Resources/filter.png" />
                                            </Button>
                                            <Button Width="24" Height="24" ToolTip="Group">
                                                <Image Source="../Resources/group.png" />
                                            </Button>
                                        </ToolBar>
                                    </ToolBarTray>
                                    ...
4

1 に答える 1

0

動作するようになりました。

私はすでに昨日それを試したと確信していますが、今では次のように動作します:

<ToolBarTray Orientation="Vertical" Grid.Row="1" Grid.Column="2" IsLocked="True">
    <ToolBar Band="1" BandIndex="1" >
        <Button Width="24" Height="24" ToolTip="Sort">
            <Image Source="pack://application:,,,/PControls;component/Resources/sort.png" />
        </Button>
        <Button Width="24" Height="24" ToolTip="Filter">
            <Image Source="pack://application:,,,/PControls;component/Resources/filter.png" />
        </Button>
        <Button Width="24" Height="24" ToolTip="Group">
            <Image Source="pack://application:,,,/PControls;component/Resources/group.png" />
        </Button>
    </ToolBar>
</ToolBarTray>
于 2012-07-21T15:10:14.173 に答える