1

我有

<Image x:Name="imgScreenshoot" Margin="2" Source="{Binding Converter={StaticResource ImageConverter1}}" />

在一个ResourceDictionary

同时它有

<local:ImageConverter x:Key="ImageConverter1" />

在设计模式下没有错误。

但是当我启动应用程序时,我得到了那个应用程序的错误。无法解析参考 ImageConverter1

我该如何解决?谢谢!


 <UserControl.Resources>
        <ResourceDictionary>
            <DataTemplate x:Key="DataTemplateScreen">
                <Border Height="250" Width="250" BorderBrush="#FF3798F1" BorderThickness="2" CornerRadius="5" >
                    <Grid Margin="2,2,2,2" VerticalAlignment="Stretch"  HorizontalAlignment="Stretch">
                        <Grid.Background>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFF0F8FE" Offset="0"/>
                                <GradientStop Color="#FFE0F3FE" Offset="0.3"/>
                                <GradientStop Color="#FF6FA7C5" Offset="1"/>
                            </LinearGradientBrush>
                        </Grid.Background>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid x:Name="brdNameActionButtons" Grid.ColumnSpan="3" Margin="0">
                            <Grid.Background>
                                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                    <GradientStop Color="#FFDCF0FA" Offset="0"/>
                                    <GradientStop Color="#FFC5E6F7" Offset="0.2"/>
                                    <GradientStop Color="#FF297CCA" Offset="1"/>
                                </LinearGradientBrush>
                            </Grid.Background>
                            <TextBlock x:Name="txbName" Text="{Binding Name}" Margin="2" Grid.Row="0" FontWeight="Bold" FontSize="12" Grid.Column="0" HorizontalAlignment="Left" Foreground="Black" FontFamily="Segoe UI" />
                            <TextBlock x:Name="txbUpdated" Text="{Binding Screenshot.Refreshed}" Margin="2" Grid.Row="0" FontWeight="Bold" FontSize="12" Grid.Column="0" HorizontalAlignment="Right" Foreground="Black" FontFamily="Segoe UI" />
                        </Grid>
                        <Border x:Name="brdScreenshoot" Grid.Column="2" Margin="2" Grid.Row="3"   CornerRadius="5" >
                            <Grid >
                                <Image x:Name="imgScreenshoot" Margin="2" Source="{Binding Converter={StaticResource ImageConverter1}}" />
                            </Grid>
                        </Border>
                        <StackPanel Grid.Column="2" Grid.Row="1"  Orientation="Horizontal"  HorizontalAlignment="Center" Margin="0,2">
                            <Button Content="Play"  HorizontalAlignment="Center" Height="23" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="42" Grid.Row="1"/>
                            <Button Content="Stop"   HorizontalAlignment="Center" Height="23" Margin="2,0,0,0" VerticalAlignment="Bottom" Width="42" Grid.Row="1"/>
                            <Button Content="Cancel"   HorizontalAlignment="Center" Height="23" Margin="2,0,0,0" VerticalAlignment="Bottom" Width="42" Grid.Row="1"/>
                            <Button Content="Refresh"   HorizontalAlignment="Center" Height="23" Margin="10,0,0,0" VerticalAlignment="Bottom" Width="42" Grid.Row="1"/>
                        </StackPanel>
                    </Grid>
                </Border>
            </DataTemplate>
            <ItemsPanelTemplate x:Key="MonitorPlayersItemsPaneltemplate">
                <toolkit:WrapPanel/>
            </ItemsPanelTemplate>
            <local:ImageConverter x:Key="ImageConverter1" />
        </ResourceDictionary>
    </UserControl.Resources>
4

1 回答 1

2

在使用之前将转换器声明得更高。

于 2012-04-09T20:47:56.153 回答