|
Ah that makes sense!
In my case I wanted to provide a visual indication that text items where different.
I didn't care about the colour used though, so I originally created a random colour in a collection in the VM and it was that collection I was trying to lookup.
But I realised that as long as the colour was the same for the same string, then the conversion from string to colour had nothing to do with my model or viewmodel.
So I created an IValueConvertor:
public class StringToColorConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is string))
throw new ArgumentException("value is not a string");
string text = (string) value;
byte[] data;
using (MD5 md5 = MD5.Create())
data = md5.ComputeHash(Encoding.UTF8.GetBytes(text));
return new SolidColorBrush(Color.FromArgb(150, data[0], data[7], data[15]));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
If your using similar ish strings you might get colours close together, but for my set of 5 pairs, each colour was different enough to be recognizable.
|
|
|
|
|
Hi All,
I have developed an application in WPF with SQL server as database and the database table contains image data types also.
My data base server is and centralized one and am accessing it via internet thorough sql adapter.
Problem
Now i have problem that it is taking more time to fetch the image data type records and also normal data also taking much time to fetch via internet.
Clarification
1) I have an idea to convert this application to web so that the application server and the database server in the same box will retrive it faster and give the result.
My application is in WPF, the best easy method is to convert it into silver light or wpf browser appliation? if it is wpf browser application can i host it into iis?
2) Or can i have the wpf application as such and change the database hit to the webservices? will webservice respond faster for data fetching also with the image data types?
thanks in advance for your time in helping me pulling out of this crisis.
|
|
|
|
|
A WPF application can be hosted on IIS by making it an xbap (WPF browser based) application[^].
However, in your case, this will still not solve the performance issue you are facing with images.
Optimizing WPF Application Performance [^] might help you try to render images faster.
|
|
|
|
|
Dear Abhinav,
Thanks for your time in replying to my question.
You mentioned that eventhough my application after converted to xbap application it wont work for images.
But my question is, am going to host the database server and the IIS server in the same machine. In that case it should work fine right?
my windows application is working fine for this case.. when my application and the database server in the same machine its working fine.
But i have one doubt. I read in the google that when ever user clicks the xbap , it will internally handles the exe downloads and all.
Which means that everytime the user clicks the link will it downlaod the exe application? and will it run from local machine?
can you please help me to get clarified on this?
that is the case once again its going to be a windows application and will have same image problem?
modified 5-Nov-12 6:13am.
|
|
|
|
|
Hi,
I have few input controls in my ClaimsReport.xaml, based on the user input i have to hit the database fetch records and display those records in UI with header & footer. Along with I have to provide print option to generate the report with header and footer & export to Excel, .csv, .txt formats. Please suggest or share me how to achieve it. Refer the below screenshots.
<a href="C:\Users\sathees_km\Documents\Claims Report.jpg">Window Design</a>
<a href="C:\Users\sathees_km\Documents\Report Data.jpg">Report Data</a>
Regards,
Satheeskumar Manickam
modified 30-Oct-12 6:50am.
|
|
|
|
|
Please explain more clearly what your problem is; I don't think anyone is going to write this code for you.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
As Silverlight does not have a decent reporting interface we use SSRS to create an embedded (local RDLC report) this is generated in the WCF on the server where there are no restrictions on data. The report is passed to the SSRS on the server and exported to a PDF file.
This PDF is then passed back to the client as a binary file and displayed via Telerik PDF viewer.
I'm not sure whether this is a valid solution for you but it has a number of benefits:
SSRS is excellent for building and maintaining reports
The same report can be used in SSRS server
I don't need a dedicated SSRS Viewer (approx $500) I can used any Silverlight PDF viewer
I don't need to deal with the export issues, Telerik does all that out of the box.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Are you saying that your chart component is a WinForms component which you are trying to use in a WPF application? If so, you don't need to worry about DPs (the shorthand name for Dependency Properties). The big question I have to ask here, is have you added the control into a WindowsFormsHost container? An example would look like this
<Grid>
<WindowsFormsHost>
<myNamespace:MyChartControl />
</WindowsFormsHost>
</Grid> Then, you just add your configuration as you see fit.
|
|
|
|
|
Hi Pete.
No, I have modified the chart so that it can be used in WPF applications without WinFormsHost. It's a WPF component without DP's. The chart object itself is derived from ContentControl but it's properties and their sub-properties are normal classes - not derived from Dependency Object.
modified 15-Dec-21 21:01pm.
|
|
|
|
|
What does the rest of the exception say?
|
|
|
|
|
That is all it says. It's a small message box that says "An exception has been thrown" or something like that and it has a "Details" button which shows "Exception of type 'MS.Internal.Validate+ValidationFailure' was thrown.".
modified 15-Dec-21 21:01pm.
|
|
|
|
|
Have a look in EventViewer. I suspect you'll find a fuller message there.
|
|
|
|
|
Nothing there.
modified 15-Dec-21 21:01pm.
|
|
|
|
|
Unfortunately, there's not enough context there to figure it out I'm afraid. Do you have VS SP1 installed?
|
|
|
|
|
|
It could well be. Is there a reason that you can't use your WinForms version? As you know that's stable, you could be getting by with that while you sort out the chart.
On a different note, you can achieve a lot of what you want to do if you embrace MVVM architecture and use that as the underlying mechanism for getting data into your charts. It's a lot simpler model to get your head around than DPs so it could save you a lot of grief.
|
|
|
|
|
To be exact, there are two versions of the chart: WinForms (VS2008) and WPF (VS2010). WPF version uses the same classes as the WinForms version but I use conditional compiling to make the necessary modifications to source code.
The WPF version works well if you configure it in code-behind but my boss wants the WPF version to work in WPF/XAML designer as well so what can I do. Many our customers want the WPF version (the younger generation of software developers) so there's not much I can say. Since there's the air-space problem when using WinFormHost it's out of the question.
MVVM is a good option but I cannot use it right now. It would take a pretty long time to convert the current source code to match MVVM ideology. Perhaps in the future chart versions MVVM will be implemented one step at a time...
modified 15-Dec-21 21:01pm.
|
|
|
|
|
|
I changed the view property and the X axis list to dependency properties but no luck. Then I created a new class (XAxes) that implements IList<axisx> and IList (and replaced the List<axisx> property in the view class with that) so I could debug if accessing the X axis list doesn't work. Didn't see anything wrong with that. But when I add two X axes in addition to the already created X axis this exception pops out in designer: http://postimage.org/image/8an21q0jr/[^]
Here's the whole stack trace:
System.ArgumentOutOfRangeException
Specified argument was out of the range of valid values.
Parameter name: index
at MS.Internal.VirtualModel.VirtualModelItemCollection.Insert(Int32 index, IVirtualModelItem item)
at MS.Internal.VirtualModel.VirtualModelItemCollection.Insert(Int32 index, Object value)
at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelItemCollectionAggregate.<>c__DisplayClassc.<Insert>b__8(ChangeEntry change, Int32 i)
at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelItemCollectionAggregate.ManageCollections(SetupDelegate setup, IterationDelegate iterate, NotifyChangeDelegate notifyChange, ReturnValueDelegate returnValue)
at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelItemCollectionAggregate.Insert(Object value, Int32 index)
at MS.Internal.Designer.PropertyEditing.Model.Properties.ModelPropertyValueCollection.Insert(Object value, Int32 index)
at MS.Internal.Designer.PropertyEditing.FromExpression.Framework.PropertyInspector.CollectionDialogEditor.AddItem()
at MS.Internal.Designer.PropertyEditing.FromExpression.Framework.PropertyInspector.CollectionDialogEditor.OnQuickTypesCurrentChanged(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Data.CollectionView.OnCurrentChanged()
at System.Windows.Data.ListCollectionView.MoveCurrentToPosition(Int32 position)
at System.Windows.Data.CollectionView.MoveCurrentTo(Object item)
at MS.Internal.Designer.PropertyEditing.Editors.CollectionDialogEditor.OnAddNewItem(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)
at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)
at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)
at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Something pretty weird is going on when inserting elements to the list. Well, I'm out of ideas. I'm probably going to have to tell people not to use XAML code or designer in WPF until this problem is solved. Put "[Browsable(false)]" on every property or something...
modified 15-Dec-21 21:01pm.
|
|
|
|
|
I have two listbox binded with the same collection. I want to have different content in both the listbox using the same collection by doing filtering.
How can i achieve my target using wpf and mvvm?
|
|
|
|
|
Take a copy of the collection so you have 2 distinct collections to bind to!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi all,
I have a WPF application that needs to be universal across XP, Vista, Win 7 and Win 8. I have it working on all apart from XP, the reason it doesn't work is I get an error message
The image decoder cannot decode the image. The image might be corrupted
The error is being caused by the image I have the MainWindows Icon property. The image is a .ico file which resides in my resources.
I would suspect that the image is corrupted except when I run it on all other OS's I have no problems. Has anyone ever come across any problems with XP struggling to accept a .ico image? and if so how do you suggest I go about this?
Thanks!
|
|
|
|
|
Can you open your icon with some other program on XP? If not, you'll have to change it so that it can be opened there (it's best to create it on an XP machine).
|
|
|
|
|
It is a .ico file - I think these are incompatible with Windows XP but that's just a guess. I'm just going to create a separate library of images with a different file type and see what the outcome is.
|
|
|
|
|