|
Ok found this article showing how to do the style once, then use "based on" to apply it to other controls.
|
|
|
|
|
I have a report file connected to a data table.
DataTable dt = BizObject.GetDriversInspectionReportData(dvirs);
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DVIRReportData";
reportDataSource.Value = dt;
string reportFile = @"..\Reports\DVIRReport.rdlc";
ReportViewerView rvv = new ReportViewerView("Driver's Inspection Report", reportFile, reportDataSource);
rvv.ShowDialog();
When I get the data it comes back with multiple rows, yet when the report viewer comes up , there's always just one page. I'm not seeing any other pages.
Any idea what's wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I am using the standard report that ships with VS 2010 (rdlc).
I don't see a checkbox in the toolbox. Can I somehow get a checkbox on a report using the standard reporting?
If it's not broken, fix it until it is
|
|
|
|
|
A CheckBox is an interactive element, but a report is static, hence it does not make sense.
If you want to display a Boolean value in that style, you could use images, and add the "checked" image for true, the "unchecked" image for false instead.
|
|
|
|
|
Bernhard Hiller wrote: A CheckBox is an interactive element
True, but you still might want to print a checkmark..
I added a Rectangle with a checkmark image inside. I set the image's Visible based on the bool field in the data.
If it's not broken, fix it until it is
|
|
|
|
|
Apologies if the question isn't clear, I'm struggling to find the right terminology.
I have a entity that has properties which are the same entity i.e.:
public class Unit
{
public int Id {get;set;}
public string Name {get;set;}
public int ParentUnitId {get;set;}
}
On my WPF form I'd like a combobox for the user to select which Unit is the ParentUnitId.
So far I've gotten it by using a List, but this a) doesn't update if you add a new Unit, b) doesn't seem 'right', I feel like I should be able to achieve this with binding alone.
<ComboBox ItemsSource="{Binding}"
DisplayMemeberPath="Name"
SelectedValuePath="Id"
SelectedValue="{Binding Path=ParentUnitId}"/>
If I just have my XAML starting the ComboBoxes ItemSources are the same source as the Form, then they act as filters/selectors and the whole form moves to that record.
I'm using a CollectionViewSource as the DataContext for my Window.
|
|
|
|
|
Don't use a List<Unit> as the collection behind your ItemsSource use ObservableCollection<Unit> as this raises change notifications when the number of items in the list changes. As far as the rest of your question goes, I'm really not clear what you're trying to achieve here.
|
|
|
|
|
Yea I understand about the List / ObservableCollection bit.
I'll have another go
On my form, which allows you enter new units and change their details, one of the details is 'which is the parent unit'. This is a combobox, which should allow the user to select from the list of units.
Its the correct setup of this combobox that I'm having problems with.
I *think* I should be able to achieve this with pure XAML, but I'm not sure how.
As I think the pure XAML solution will also have the advantage that if a new unit is added on the form, the combobox lists will all contain the new unit (as they're all the same source in some sense), which my current solution of a List wont have. And unless I've missed something, just changing List to ObservableCollection wont resolve that will it?
|
|
|
|
|
It would help if you could show us your ViewModel. That way I should be able to get a clearer idea. As it is, I can see 3 or 4 things that you could be asking for and I'd hate to send you up a blind alley. Oh, and if you need to add new items, you definitely need the OC. A list will not notify the ComboBox that there are new items.
|
|
|
|
|
Ah, well right now we're not using VM. There's not a massive amount of experience, so we want to start slow and with what we're used to, so thats CodeBehind.
I've pasted, the XAML, Code Behind and entity here (given the size didn't seem sensible to flood the forum)
Pastie[^]
So each Unit has three fields (BusinessAreaId, DivisionalUnitId, ParentUnitId), that also reference a Unit, so I would like 3 comboboxes each with a list of units inside, and ideally as you add units, then the combobox items also grow.
My current ef entity load code is:
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (s, ev) =>
{
this.Dispatcher.Invoke(new Action(() =>
UIHelper.ProgressBarRun(true)));
context.Units.Load();
context.UnitTypes.Load();
unitNames = new ObservableCollection<UnitName>(
context.Units.Local.Select(f => new UnitName() { Id = f.Id, Name = f.Name }));
};
worker.RunWorkerCompleted += (s, ev) =>
{
viewSource.Source = context.Units.Local;
unitTypeIdComboBox.ItemsSource = context.UnitTypes.Local;
businessAreaIdComboBox.ItemsSource = unitNames;
divisionalUnitIdComboBox.ItemsSource = unitNames;
parentUnitIdComboBox.ItemsSource = unitNames;
this.Dispatcher.Invoke(new Action(() =>
{
UIHelper.ProgressBarRun(false);
navFirstButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}));
};
worker.RunWorkerAsync();
|
|
|
|
|
Resolved it, adding design time data helped...though weirdly with it working the design time data now looks wrong.
I'm not 100% this is fully correct, or the best or simplest way of doing this...but it does seem to work so far. I've got a few CollectionViewSource s, but the first and last are the only two relevant to this.
<Page.Resources>
<CollectionViewSource x:Key="unitViewSource"
Source="{Binding}" />
<CollectionViewSource x:Key="unitsServicesViewSource"
Source="{Binding Path=Services, Source={StaticResource unitViewSource}}" />
<CollectionViewSource x:Key="unitTypeViewSource"
d:DesignSource="{d:DesignData Source=/SampleData/UnitTypeSampleData.xaml}" />
<CollectionViewSource x:Key="unitNameViewSource" />
I needed the CollectionViewSource unitNameViewSource, so that I could set the ItemsSource on the ComboBox to something. If I didn't set it, or set it to {Binding} I got false values on the first record.
The ComboBox s are defined as:
<ComboBox Grid.Column="1"
Grid.Row="1"
Margin="3"
Name="businessAreaIdComboBox"
DisplayMemberPath="Name"
SelectedValuePath="Id"
SelectedItem="{Binding Path=BusinessArea}"
ItemsSource="{Binding Source={StaticResource unitNameViewSource}}">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.InputBindings>
<KeyBinding Key="Delete"
Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=ClearComboBoxCommand}"
CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ComboBox}, Path=Name}" />
</ComboBox.InputBindings>
</ComboBox>
The other thing I think was important was to bind to BusinessArea and not the BusinessAreaId column. Let EF faff with translating that!
My code behind is then:
private void Page_Loaded(object sender, RoutedEventArgs e)
{
viewSource = ((CollectionViewSource) (this.FindResource("unitViewSource")));
try
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (s, ev) =>
{
this.Dispatcher.Invoke(new Action(() =>
{
UIHelper.ProgressBarRun(true);
this.IsEnabled = false;
}));
context.Units.Load();
context.UnitTypes.Load();
};
worker.RunWorkerCompleted += (s, ev) =>
{
viewSource.Source = context.Units.Local;
unitTypeIdComboBox.ItemsSource = context.UnitTypes.Local;
UpdateComboBoxes();
this.Dispatcher.Invoke(new Action(() =>
{
UIHelper.ProgressBarRun(false);
navFirstButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
this.IsEnabled = true;
}));
};
worker.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void UpdateComboBoxes()
{
var unitNames = context.Units.Local;
businessAreaIdComboBox.ItemsSource = unitNames;
divisionalUnitIdComboBox.ItemsSource = unitNames;
parentUnitIdComboBox.ItemsSource = unitNames;
}
If I used the unitNameViewSource, and set it (even to the same Units.Local), I got the issue where all three combo boxes displayed the same value. So I need the ViewSource, for the XAML ItemsSource binding, but then overwrite it in code...as I said this probably isn't the right way
The UpdateComboBoxes method is just a hangover from when I thought I would need to refresh them all after adding a new unit.
|
|
|
|
|
I have a NotificationInformation class which contains properties together with property changed events:
public string EmailUser
{
get { return _emailUser; }
set
{
_emailUser = value;
OnPropertyChanged("EmailUser");
}
}
The NotificationInformationRepository class contains the NotificationInformation classes in a List of NotificationInformation classes (List<NotificationInformation> )
When OnPropertyChanged fires on a NotificationInformation instance I want to be able to serialize the NotificationInformationRepository data in the List.
I have the serialization working correctly - my question is how do I go about subscribing to or picking up the OnPropertyChanged events from within the NotificationInformationRepository class?
I realise this is a basic WPF question but I am feeling dumb this weekend being unable to code this.
-----------------------------------------------------------------------------------------------------
Solution:
In NotificationInformation I have declared a delegate:
public delegate void ItemChanged();
[field: NonSerialized]
public ItemChanged ItemHasChanged;
public NotificationInformation(ItemChanged _itemChanged)
{
ItemHasChanged = _itemChanged;
}
public string EmailUser
{
get { return _emailUser; }
set
{
_emailUser = value;
OnPropertyChanged("EmailUser");
ItemHasChanged();
}
}
When I add a NotificationInformation to the NotificationInformationRepository List I pass in a reference to a method in NotificationInformationRepository that is used as the delegate.
It's not pretty
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
You are *way* over-thinking it (and you're right, what you did is not pretty and kinda breaks OO principles) . When you add an item to the NotificationInformationRepository, just subscribe to the INotifyPropertyChanged event. Your subscription handler would just be a method that does Save() or whatever you do to save the repository.
If you want to encapsulate it (which I would), you'd just add a new Add() overload to the NotificationInformationRepository that subscribes to the event. Of course, if you want to clean up properly, you should unsubscribe in a Delete() method and in the finalizer.
|
|
|
|
|
Thanks!
I subscribed to the INotifyPropertyChanged event and it worked.
I knew I was missing something obvious, I'm reasonably new to WPF and as you say this was over-thinking the issue.
I will look into the encapsulation suggestion.
Thanks again
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
I need a reporting tool for use in a WPF app.
Requirements:
1. Preferably free
2. The report will probably NOT be too complex, so I don't need anything too complicated.
3. Easy to learn
4. Easy to deploy.
Any suggestions?
Thanks!
If it's not broken, fix it until it is
|
|
|
|
|
Hi, may be you want to try this[^].
The best not free Reporting tool, for me is this[^].
--
Christian Amado
Software Engineer | MCPD: Windows Phone Developer | MCTS: Silverlight Developer
Please mark as answer, if helped you.
|
|
|
|
|
You pointed me to Telerik. I downloaded their Reporting Q2 2014 samples.
I can't get it to compile. There are 4 or 5 themes files that have to be included, or the viewer doesn't show up. Their tech support sent me this[^].
I followed it, and they theme files won't compile. Seems they are referencing other Telerik assemblies or namespaces that either don't exist or are wrong.
What version of their reporting are you using? Have you got this working?
If it's not broken, fix it until it is
|
|
|
|
|
Have you had a look at this[^]?
|
|
|
|
|
Pete,
I downloaded it.. I don't see a designer anywhere... Am I missing something?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
It uses XAML so it doesn't have a designer. That wasn't a requirement in your list. To be honest, the XAML is nice and clean. This is the sample Image report:
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xrd="clr-namespace:CodeReason.Reports.Document;assembly=CodeReason.Reports"
xmlns:xrbc="clr-namespace:CodeReason.Reports.Document.Barcode;assembly=CodeReason.Reports"
PageHeight="29.7cm" PageWidth="21cm" ColumnWidth="21cm">
<xrd:ReportProperties>
<xrd:ReportProperties.ReportName>ImageReport</xrd:ReportProperties.ReportName>
<xrd:ReportProperties.ReportTitle>Image Report</xrd:ReportProperties.ReportTitle>
</xrd:ReportProperties>
<xrd:SectionReportHeader PageHeaderHeight="2" Padding="10,10,10,0" FontSize="12">
<Table CellSpacing="0">
<Table.Columns>
<TableColumn Width="*" />
<TableColumn Width="*" />
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>
<Paragraph>
<xrd:InlineContextValue PropertyName="ReportTitle" />
</Paragraph>
</TableCell>
<TableCell>
<Paragraph TextAlignment="Right">
<xrd:InlineDocumentValue PropertyName="PrintDate" Format="dd.MM.yyyy HH:mm:ss" />
</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</xrd:SectionReportHeader>
<xrd:SectionReportFooter PageFooterHeight="2" Padding="10,0,10,10" FontSize="12">
<Table CellSpacing="0">
<Table.Columns>
<TableColumn Width="*" />
<TableColumn Width="*" />
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>
<Paragraph>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph TextAlignment="Right">
Page
<xrd:InlineContextValue PropertyName="PageNumber" FontWeight="Bold" /> of
<xrd:InlineContextValue PropertyName="PageCount" FontWeight="Bold" />
</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</xrd:SectionReportFooter>
<Section Name="ReportBody" Padding="80,10,40,10" FontSize="12">
<Paragraph FontSize="24" FontWeight="Bold"><xrd:InlineContextValue PropertyName="ReportTitle" /></Paragraph>
<Paragraph>This is an image report example.</Paragraph>
<Paragraph FontSize="16" FontWeight="Bold">
Static Image
</Paragraph>
<Paragraph>
<Image Tag="dpd.jpg" Width="10cm" />
</Paragraph>
<Paragraph FontSize="16" FontWeight="Bold">
Dynamically created Images
</Paragraph>
<Paragraph>
<Image Name="imageDynamic1" Width="5cm" Height="5cm" />
<Image Name="imageDynamic2" Width="5cm" Height="5cm" />
</Paragraph>
</Section>
</FlowDocument>
|
|
|
|
|
Pete O'Hanlon wrote: It uses XAML so it doesn't have a designer. That wasn't a requirement in your list. To be honest, the XAML is nice and clean. This is the sample Image report:
To me it's assumed that you need a designer. Yes, XAML is nice & clean... and VERY time consuming. For anything other than a VERY simple report it would take all day to get laid out right.
I noticed on their site that someone asked for a designer. Nice idea for an add on to the project.
I can't see how any serious reporting can be done without a designer.
If it's not broken, fix it until it is
|
|
|
|
|
Kevin Marois wrote: and VERY time consuming Hmmm. I'm not sure I agree here. I can churn out XAML at a phenomenal rate.
|
|
|
|
|
I can too. Don't get me wrong. I love XAML
But for every little tweak, you would need to stop, compile, run the report (meaning fire up your app, get to the report, run it - OOPS that label isn't aligned right!!!
Stop, open XAML, tweak, repeat.
With a designer it's one & done.
If it's not broken, fix it until it is
|
|
|
|
|
If the report is simple and you have already worked getting the data to a form, maybe just roll your own print routine to generate the report? See Printing in WPF[^] for example?
|
|
|
|
|
If you want a report designer then you could always look at SyncFusion reports[^]. I'm a big fan of SyncFusion now. They have worked hard on the performance of their WPF products, and this really shows.
|
|
|
|