|
Give me some help please!
|
|
|
|
|
hi error,
There are plenty much commercial solutions out there. Try Google with 'WPF Reporting'.
If you want to keep things simpler and are not afraid of writing a little bit code, you could do the job with WPF's FlowDocument.
Just bind the corresponding fields to TextBlock / TextBox items in the Document and voila ...
First step : Create a FlowDocument with it's content and placeholders.
( This is maybe a very poor example, but it should give you a kick into the right direction )
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
ColumnWidth="400" FontSize="14" FontFamily="Georgia">
<Paragraph>
<!-- Header-->
<TextBlock Text="Header of the Report ...." />
<!-- Binding of Fields -->
<TextBlock Text="{Binding Path=DesiredFieldName}" />
<!-- Footer -->
<TextBlock Text="Footer of the Report ...." />
</Paragraph>
</FlowDocument>
Step two : Instanciate your FlowDocument ( in this case from within C# code )
string xaml = null;
StreamResourceInfo sri = Application.GetResourceStream(new Uri(@"..\Documents\Report.xaml", UriKind.Relative));
using (StreamReader reader = new StreamReader(sri.Stream))
{
xaml = reader.ReadToEnd();
}
FlowDocument myReport = (FlowDocument)XamlReader.Parse(xaml);
Step three : Bind the source to your FlowDocument ( Report ), so it's 'fields get filled' by binding.
For example with the EntityFramework as dataprovider. ( Again this is just an example ! You could do this with nearly every datasource )
using(Entities ctx = new Entities())
{
myReport.DataContext = from c in ctx.articles select c.price;
}
And finally : If you want to show your generated report, you could do so showing it in an FlowDocumentReader.
<FlowDocumentReader Name="myReportViewer" />
And now set our generated report to the Document property of the FlowDocumentReader ...
myReportViewer.Document = myReport;
Let me know if that helped you.
Cheers Doc.NET.Noodles
(PS.: Dont forget to vote if that answer helped you. )
|
|
|
|
|
Just use SQL Reporting Services - there's no need to use a pure WPF solution here.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
This is very basic BackgroundWorker Example but I dont know why the progress bar run 2 times. It should run only 1 time. anyone can help me.
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Threading
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Namespace WindowsApplication1
Partial Public Class Window1
Inherits System.Windows.Window
Private WithEvents _worker As BackgroundWorker
Public Sub New()
InitializeComponent()
End Sub
Private Sub StartWorker(ByVal sender As Object, ByVal e As RoutedEventArgs)
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
_worker = New BackgroundWorker()
_worker.WorkerReportsProgress = True
_worker.WorkerSupportsCancellation = True
AddHandler _worker.DoWork, AddressOf DoWorkEventHandler
AddHandler _worker.ProgressChanged, AddressOf ProgressChangedEventHandler
AddHandler _worker.RunWorkerCompleted, AddressOf RunWorkerCompletedEventHandler
_worker.RunWorkerAsync()
_btnStart.IsEnabled = False
_btnCancel.IsEnabled = True
End Sub
Private Sub DoWorkEventHandler(ByVal s As Object, ByVal args As DoWorkEventArgs) Handles _worker.DoWork
Dim worker As BackgroundWorker = TryCast(s, BackgroundWorker)
For i As Integer = 0 To 4
If worker.CancellationPending Then
args.Cancel = True
Return
End If
Thread.Sleep(100)
worker.ReportProgress(i + 1)
Next i
End Sub
Private Sub ProgressChangedEventHandler(ByVal s As Object, ByVal args As ProgressChangedEventArgs) Handles _worker.ProgressChanged
_progressBar.Value = args.ProgressPercentage
End Sub
Private Sub RunWorkerCompletedEventHandler(ByVal s As Object, ByVal args As RunWorkerCompletedEventArgs) Handles _worker.RunWorkerCompleted
_btnStart.IsEnabled = True
_btnCancel.IsEnabled = False
_progressBar.Value = 0
End Sub
Private Sub CancelWorker(ByVal sender As Object, ByVal e As RoutedEventArgs)
_worker.CancelAsync()
End Sub
End Class
End Namespace
|
|
|
|
|
Member 3068741 wrote: I dont know why the progress bar run 2 times. It should run only 1 time.
I don't see anything that runs twice in there.
Use your debugger - use breakpoint(s). Is button1_Click called more than once?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi,how should i use wpf draw staff gauge ?
there's lot of controls, which one is siutable for this condition?
every suggestion will be helpful, thanks a lot!
ICQ:126406887
|
|
|
|
|
it seems like this
0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15_16_
ICQ:126406887
|
|
|
|
|
Hi,
Just started with my first WPF web browser application.
Can any one tell me if WPF browser applications will run on MAC browsers ?
I am looking to create a website in WPF, just wanted to make sure the cross os browsers compatibility...
A newbie with WPF...
Regards
Vijay V.
Yash Softech
|
|
|
|
|
WPF Browser applications use the .net framework which will only run in windows.
There is a project called Mono[^] which allows you to run some .net applications on other platforms but it currently lacks wpf support.
Silverlight[^] is a subset of wpf which runs on multiple platforms[^].
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
i have an asp.net application which is a website. Now from aspx pages i want to redirect the user to
wpf application in the same window. How can this be done .
|
|
|
|
|
Is this a joke?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I need some helpyin developing the user control. I have developed a usercontrol for slider( which has a slider and a textbox for displaying the value ) , I need to add a user defined property orientation for my slider , based on which it should be rotated . Can anyone throw some light on how to define userdefined properties for the usercontrol.
Thanks
|
|
|
|
|
Namaste, or Vanakkum, or Namaskaram (your choice), Sri Krishnan,
I think you can get some clear responses if you make what you mean by "rotate" and "orientation" a little more clear.
What exactly is it you want to do beyond what setting the Orientation and IsDirectionReverse properties of a WPF Slider at design time do now.
If this is the very simple case of you just wanting to let your code at run-time set the Orientation property : well, write a public method in the UserControl you can call:
public void setSliderOrientation(Orientation whichWay)
{
this.slider1.Orientation = whichWay;
}
If this is the simple case of you wanting to expose the Slider Orientaton property inside a UserControl at Design Time : write a Public Property so that Property will show up in the Property Editor at Design Time :
public Orientation sliderOrientation
{
set { slider1.Orientation = value; }
get { return slider1.Orientation; }
}
If by "rotate" you mean literally rotating the user control itself, or rotating the slider inside the usercontrol : then : just go and take a look at how you can rotate anything in WPF.
best, Bill
"Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844
|
|
|
|
|
equivalent method Dispose()(in c#) in WPF?
|
|
|
|
|
It's still called Dispose .
[EDIT] I don't understand why this got a 1 vote. I answered the question accurately. Just because you're using WPF doesn't mean the underlying framework has changed. It's still just .Net and C#.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Sunday, July 26, 2009 3:31 PM
|
|
|
|
|
There - I balanced that out a bit.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
mehdibahadori wrote: equivalent method Dispose()(in c#) in WPF?
Huh!!! WPF is a subset of .Net Framework & it is mainly for the UI. Hence you are using C# as the backend code. So why you are asking about an equivalent method of Dispose() (in C#)??? For your information... there are no alternatives. You have to use the same... which you have to implement from IDisposable interface.
Regards,
- Kunal Chowdhury ( My Blog)
|
|
|
|
|
|
|
Attached properties need different getters and setters than regular ones...
See the example near the end of this page: http://msdn.microsoft.com/en-us/library/ms749011.aspx[^]
EDIT: Oh, and make sure you really want an attached property here. You might want to use a regular dependency property, then bind it using a RelativeSource with FindAncestor.
|
|
|
|
|
|
Sure... Here's the quick and dirty on both...
Dependency Property = Just a property on a class that automatically updates data binding (At the cost of a little overhead)
Attached Dependency Property = A property that goes down the tree. Think of DockPanel.Dock. It's made so child controls can have a value, but the parent stores them and can act on them. It's most similar to the old ExtenderProviders from WinForms.
As for the binding... Data binding is actually one of the more annoying parts of WPF, but it's great once you get it right. I still have to use references pretty often for the more complicated binding sources...
Every control has what's called a DataContext. This is just any old object you assign to it. It's the source for any data binding. So if you say "{Binding IsValidNewSet}", the first place it will look is in the button's DataContext property. Since it doesn't have one, it'll crawl up the tree and check the Grid's DataContext (Also missing), then the Window's DataContext... It doesn't find one, so you'll have problems.
Now, you COULD set the window's datacontext to itself in the code-behind, so the button would eventually see the Window as its datacontext and get the IsValidNewSet property. It's not the best way though...
The simplest way is to bind by name. Give the window a name in XAML, for example "MyWindow". Then use this binding for the button:
IsEnabled="{Binding ElementName=MyWindow,Path=IsValidNewSet}"
Come to think of it, I was going to post the code for a FindAncestor call, but that might be overkill... I'd say just use ElementName. This overrides the normal behavior and looks at a named element instead of the DataContext.
|
|
|
|
|
|
Ahhh, ok, you're doing this as a UserControl. Then you DEFINITELY want to use FindAncestor instead of ElementName. WPF has some limitations when it comes to XAML-defined UserControls, and those get worse if you start naming their component elements.
You won't run into most of the annoyances unless you start templating, but it's still something to watch out for.
Oh, but the name you define inside the UserControl is an internal name, so instantiating it elsewhere would not override it in this sense.
|
|
|
|
|