<telerik:RadToolBar Grid.Row="0"> <!--<telerik:RadButton Command="{Binding NavigateBackCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/NavBack.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadButton Command="{Binding NavigateForwardCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/NavForward.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadToolBarSeparator/>--> <telerik:RadButton Command="{Binding RefreshReportCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/Refresh.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadToolBarSeparator/> <telerik:RadButton Command="{Binding MoveToFirstPageCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/FirstPage.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadButton Command="{Binding MoveToPreviousPageCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/PrevPage.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadToolBarSeparator/> <TextBox IsEnabled="{Binding IsMoveToPageEnabled}" Margin="10,0,0,0" MinWidth="30" TextAlignment="Center" Text="{Binding PageNumber, Mode=TwoWay}" VerticalAlignment="Center"/> <TextBlock Margin="2,0,10,0" TextAlignment="Center" VerticalAlignment="Center"> <TextBlock.Text> <Binding ConverterParameter="of {0} pages" Path="PageCount"> <Binding.Converter> <tr:FormatedNumberConverter/> </Binding.Converter> </Binding> </TextBlock.Text> </TextBlock> <telerik:RadToolBarSeparator/> <telerik:RadButton Command="{Binding MoveToNextPageCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/NextPage.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadButton Command="{Binding MoveToLastPageCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/LastPage.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadToolBarSeparator/> <telerik:RadToggleButton Command="{Binding TogglePrintPreviewCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2" Visibility="{TemplateBinding ViewModeToggleVisibility}"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/PrintPreview.png"/> </Image.Source> </Image> </telerik:RadToggleButton> <telerik:RadButton Command="{Binding PrintReportCommand}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/Print.png"/> </Image.Source> </Image> </telerik:RadButton> <telerik:RadToolBarSeparator/> <telerik:RadComboBox Height="24" Margin="1,0" MaxDropDownHeight="300" Padding="2,0" Width="45"> <telerik:RadComboBox.EmptySelectionBoxTemplate> <DataTemplate> <Image HorizontalAlignment="Left" Height="16" Visibility="Visible" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/Export.png"/> </Image.Source> </Image> </DataTemplate> </telerik:RadComboBox.EmptySelectionBoxTemplate> <telerik:RadComboBox.ItemTemplate> <DataTemplate> <TextBlock MinWidth="150" Text="{Binding Description}"/> </DataTemplate> </telerik:RadComboBox.ItemTemplate> <telerik:RadComboBox.SelectionBoxTemplate> <DataTemplate> <Image HorizontalAlignment="Left" Height="16" Visibility="Visible" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/Export.png"/> </Image.Source> </Image> </DataTemplate> </telerik:RadComboBox.SelectionBoxTemplate> <telerik:StyleManager.Theme> <telerik:Office_BlackTheme/> </telerik:StyleManager.Theme> </telerik:RadComboBox> <telerik:RadToolBarSeparator/> <telerik:RadToggleButton IsChecked="{Binding IsDocumentMapVisible, Mode=TwoWay}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <telerik:RadToggleButton.Visibility> <Binding Path="HasDocumentMap"> <Binding.Converter> <tr:VisibilityConverter/> </Binding.Converter> </Binding> </telerik:RadToggleButton.Visibility> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/DocumentMap.png"/> </Image.Source> </Image> </telerik:RadToggleButton> <telerik:RadToggleButton IsChecked="{Binding IsParametersAreaVisible, Mode=TwoWay}" InnerCornerRadius="0" Margin="0,2" Padding="2"> <telerik:RadToggleButton.Visibility> <Binding Path="HasParameters"> <Binding.Converter> <tr:VisibilityConverter/> </Binding.Converter> </Binding> </telerik:RadToggleButton.Visibility> <Image Height="16" Width="16"> <Image.Source> <BitmapImage UriSource="pack://application:,,,/Telerik.ReportViewer.Wpf;component/images/Parameters.png"/> </Image.Source> </Image> </telerik:RadToggleButton></telerik:RadToolBar><Telerik.Reporting> <Extensions> <Render> <Extension name="IMAGE" description="TIFF Image" visible="false" /> <Extension name="PDF" description="Adobe Acrobat PDF" visible="true" /> <Extension name="MHTML" description="Compressed Web Archive" visible="false" /> <Extension name="XLS" description="Excel" visible="false" /> <Extension name="CSV" description="Comma Seperated Values" visible="false" /> <Extension name="RTF" description="Rich Text File (RTF)" visible="false" /> <Extension name="XPS" description="Microsoft XPS Document" visible="true" /> </Render> </Extensions></Telerik.Reporting>In a report I'm working on we want to display some images based on the value of a field. For that purpose I've created a UserFunction that grabs the image out of our embedded resource pack and returns it.
This is where things get a bit ugly.
Since this is a WPF app, we use BitmapImage for storing embedded image resources. It appears that the PictureBox doesn't support BitmapImage? The exception rendered in the Picturebox is "The given key was not present in the dictionary"
To avoid using BitmapImage I've tried returning the URI to the resource, also to no avail. The URI is prefixed with pack:// and that is apparently an unsupported prefix (according to the exception message.)
Going from BitmapImage to an actual GDI+ Image is not trivial since we're running a WPF app and I would really like to avoid doing that. Physical paths are also not an option...
Any ideas?
protected void BTN_Process_Click(object sender, EventArgs e) { ReportBook reportbook = new ReportBook(); ReportViewer1.Report = null; foreach (GridDataItem si in RG_Reports.SelectedItems) { string ReportName = si.OwnerTableView.DataKeyValues[si.ItemIndex]["Report"].ToString(); Type reportType = Type.GetType(Server.UrlDecode(ReportName)); Telerik.Reporting.Report report = (Telerik.Reporting.Report)Activator.CreateInstance(reportType); report.ReportParameters["Filter"].Value = Session["FilterTextAsset"]; report.ReportParameters["FilterExA"].Value = Session["FilterExA"]; report.ReportParameters["IsActive"].Value = Session["FilterIsCheckedAsset"]; report.ReportParameters["OrgUnitId"].Value = Request.QueryString["OrgUnitId"]; report.ReportParameters["AssetId"].Value = Request.QueryString["AssetId"]; report.ReportParameters["UserId"].Value = Session["UserId"]; report.ReportParameters["IsInStock"].Value = Session["FilterIsInStockAsset"]; report.ReportParameters["IsOrder"].Value = Session["FilterIsOrder"]; report.ReportParameters["Group1"].Value = new string[] { "" }; report.ReportParameters["Group2"].Value = new string[] { "" }; report.ReportParameters["Sort1"].Value = ""; report.ReportParameters["Sort2"].Value = ""; reportbook.Reports.Add(report); } if (RG_Reports.SelectedItems.Count != 0) { reportbook.DocumentName = "Assets"; ReportViewer1.Report = reportbook; } }