|
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.
|
|
|
|
|
How does Wcf Ria Services connect Access Database?
|
|
|
|
|
I've been trying to code my first MVVM app, and I'm not sure I've got things right! I'm using
Packt Pub's WPF Cookbook 4.5 [^] as a main ref.
I have a 3 main objects, Suite, which contain 1 or more Jobs, which contain 1 or more Dependancies, and finally there's a 4th Suite Collection.
At the moment each of these are inheriting from ObservableObject (that basically just helps if INPC). And Suite contains an ObservableCollection<<Job>> , Jobs an ObservableCollection<<Dependancy>> .
Is this right? Should the model contain the INPC stuff?
My ViewModels inherits from ViewModelBase , which also inherits ObservableObject . ViewModelBase takes a generic Model parameter. Which when creating the ViewModel is set to one of the model classes above.
In the ViewModel I've got properties like this that wrap the underlying model's property:
public string Suite
{
get { return Model.Name; }
set { Model.Name = value; }
}
But I've implemented the collections as:
public IEnumerable<JobVM> Jobs
{
get { return Model.Jobs.Select(f => new JobVM(f, this) { Model = f }); }
}
I understand why the conversion to a VM is needed, but I'm not quite sure how it works when I want to add Jobs, but it seems too.
So I've been building things up, but adding/removing and editing items in the collections doesn't seem to be as smooth/easy as it should be, so I'm questioning if I've got the bottom bits right before I keep hacking away!?!
If what I've got is about right, then I'll have some more q's!
|
|
|
|
|
Everything that you bind to needs to implement INPC / INCC at some level.
So ObservableCollection<x> already implements INCC for you, but x needs to implement INPC. If you have a nested ObservableCollection<y>, that ObservableCollection will handle the INCC notifications for that collection, but y needs to implement INPC and so on.
|
|
|
|
|
That makes sense, but would you put the INPC/INCC at the model level or the ViewModel level?
From my beginners pov I can see ways of doing it either way, and questioning what I'm missing!
|
|
|
|
|
As I noted in my previous response, *EVERYTHING* that you will be binding to needs to implement INPC/INCC. That includes views, view models, models, controls, etc. Personally, I never use code behind in my views, so that's not an issue. All the other ones, you need to implement INPC/INCC at every level.
|
|
|
|
|
Hi..Can someone help me to run a silverlight(3)application on linux.I had tried to run silverlight 3 project with the help of Moonlight plug in on linux but I was not succeed ....
Please help me..!!!!!!!!!
|
|
|
|
|
How do you expect someone on a forum to help you with what is probably a setup or installation issue...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: How do you expect someone on a forum to help you with what is probably a setup or installation issue...
second your thought, however your tone looks kinda rude. Apologies if its hurt
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
ThatsAlok wrote: however your tone looks kinda rude
I was being polite, I did not call the OP a bloody idiot, which the question deserved.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I did not call the OP a bloody idiot, which the question deserved.
i am not 1voter, however will even it out
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I recommend that the next time yhou think that a poster is "a bloody idiot", you simply ignore the question and make no attempt whatsoever to answer it.
You might consider that strategy even when your judgement is somewhat less harsh than "bloody idiot". Actually, if you are not able to help the poster with his problem, in a way that the poster will experience as helpful, you don't need to post a reply, regardless of how you judge the poster's abilities.
There are far more stupid answers than stupid questions in this world.
|
|
|
|
|
Oh dear have I offended your sensibilities, tough. For a start I did not call the OP a bloody idiot as he deserved, I discussed the quality of his question with ThatsAlok.
The original question was dumb, which I happily implied. I also pointed him to the most probable areas causing the unspecified problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This may sound a bit Armature but here it is.
What is the Form_load equivalent for a C#-Silverlight.
I have to Add shapes based on the available data.
1. I tried Putting the code in the MainPage() that does not work as the canvas actual height is NAN.
2. UserControl_Load() doesn't Work too.
I have to add any number of shapes so I can't add add them on design time.
Please Help
Thanks
|
|
|
|
|
|
It's the "Loaded" event.
void MyUserControl_Loaded(object sender, RoutedEventArgs e)
{
}
To set up the event handler, you can use
this.Loaded += MyUserControl_Loaded in code behind, or
Loaded="MyUserControl_Loaded" in XAML
|
|
|
|
|
I'm using the WPF Extended Toolkit PropertyGrid (v1.7), and I'm trying to setup a custom editor to display a dialog box when the user clicks a button. My problem is that I can't get the property grid to display the editor panel at all.
I tried doing it this way, but it wouldn't display, and after some investigation in the debugger, I noticed that the template's VisualTree was null:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
{
public CDSceneSelectorEditor()
{
string template =
@"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
// xmlns:pe='clr-namespace:System.Activities.Presentation.PropertyEditing;assembly=System.Activities.Presentation'>
<DockPanel LastChildFill='True'>
<pe:EditModeSwitchButton TargetEditMode='Dialog' Name='EditButton'
DockPanel.Dock='Right' Content='...' />
<TextBlock Text='Picture' Margin='2,0,0,0'
VerticalAlignment='Center'/>
</DockPanel>
</DataTemplate>";
try
{
using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template)))
{
this.InlineEditorTemplate = (DataTemplate)(XamlReader.Load(sr));
}
}
catch (Exception ex)
{
if (ex != null) {}
}
}
}
So, I figured that the visual tree must be the issue, so I tried it this way, which gave me a VistalTree , but didn't change the outcome:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
{
public CDSceneSelectorEditor()
{
var button = new FrameworkElementFactory(typeof(EditModeSwitchButton))
{ Name = "EditButton" };
button.SetValue(DockPanel.DockProperty, Dock.Right);
button.SetValue(EditModeSwitchButton.TargetEditModeProperty,
PropertyContainerEditMode.Dialog);
button.SetValue(EditModeSwitchButton.ContentProperty, " ... ");
button.SetValue(TextBlock.MarginProperty, new Thickness(0,0,3,0));
var image = new FrameworkElementFactory(typeof(Image))
{ Name = "ThumbnailImage" };
image.SetValue(Image.StretchProperty,
System.Windows.Media.Stretch.Uniform);
var panel = new FrameworkElementFactory(typeof(DockPanel));
panel.AppendChild(button);
panel.AppendChild(image);
DataTemplate template = new DataTemplate();
template.VisualTree = panel;
this.InlineEditorTemplate = template;
}
}
I am out of ideas, and google has been no help at all.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Hi,
0 down vote favorite
I am learning to draw a line graph inside my WPF. i found a tutorial of a horizontal line graph at this side: http://www.c-sharpcorner.com/uploadfile/mahesh/line-chart-in-wpf/ and i manage to plot it. But my question is how to draw a vertical graph?
I taking the example of the graph from the website i provided, if transform the graph to the vertical graph. The X-axis will be the int(on the top) and the Y-axis will be the Date(at the left hand side). Anyone can help me out?
The graph i want should be like this: http://imageshack.us/photo/my-images/202/capturegfj.jpg/
Thanks.
|
|
|
|
|