|
Figured out the problem. I changed the line:
pnlStatusArea.AddHandler(pageCfgBrushes.BrushSelectionChangedEvent, new RoutedEventHandler(UpdateStatusBar));
to:
this.AddHandler(pageCfgBrushes.BrushSelectionChangedEvent, new RoutedEventHandler(UpdateStatusBar));
And it works.
So... In trying to evaluate what happens here (so we can learn from it), apparently the original code line sets up a listener in the visual tree level of the pnlStatusArea but we then don't receive the event at the 'this' level of the visual tree. Or at least were not 'listening' for it at the 'this' level.
If anyone with more experience with this can elaborate or comment further about the details and rules of this stuff, it will be appriciated. I'd love to see a good article about this with cartoons and such. I know theres some articles out there but I haven't come across one that focuses on just this type of configuration without going into all sorts of other aspects of routed events that just gets confusing to the interested points here.
Thank You
|
|
|
|
|
I get a feed from Microsoft Silverlight and they keep sending me posts from as far back as 2008. Wondering if anyone else (who subscribes to their feed) is getting them or if there is just something weird about my subscription. I mean who really cares about Silverlight 1.1 any more.
Thanks
"You get that on the big jobs."
|
|
|
|
|
I'snt there any way to unsubscribe?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I could unsubscribe but then I won't get the new posts either. I was just curious to see if anyone else was having the same problem.
"You get that on the big jobs."
|
|
|
|
|
hi,
i am looking for an easy way to draw a pitch circle in wpf, based on center coordinates, radius, start angle and end angle.
i really searched quite a time, but all I found was either extrem complex, or does not work.
i would be very thankful, if someone could give me an example or hint to solve my problem.
best regards
pet
|
|
|
|
|
You could start from here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I have a Winform App .net framework 3.5 that makes large use of GDI+ system.drawing.drawing2D libary and I want to host it in a web page.
I think I should migrate it to Silverlight so I'm looking for some articles/examples that help me evaluate if this is the right approach.
I'm very new in Silverlight. I googled and found that system.windows.shapes library should be the library to use in Silverlight.
I also found WritableBitmapEX from Codeplex as a different possible library.
QUESTION: Is Silverlight the right solution to get the new app hosted in a web page?
Is there some example that can help me in converting the Winform GDI+ program login in Silverlight?
thanks
|
|
|
|
|
GDI / GDI+ are not used in Silverlight / WPF. Do NOT use WritableBitmap. It is VERY slow. If you are going to go to Silverlight, throw out your code and do it right. Silverlight is a whole new ball game. You don't do stuff at the pixel level anymore. Silverlight has a bunch of shape primitives that you piece together. Line, circle, rect, etc.
|
|
|
|
|
As I said I'm very new of Silverlight and even WPF so I'm trying to understand wich approach could solve my problem.
From my undestanding you are suggesting me to rewrite my GDI+ calls and all the program logic around using Silverlight Shape library as the better solution. Is that correct?
Take a look at this http://writeablebitmapex.codeplex.com. What do you think about?
|
|
|
|
|
As I said, do NOT use that if you are going Silverlight / WPF. VERY bad idea.
1) it is very slow
2) it defeats the whole purpose of Silverlight / WPF.
You need to understand Silverlight / WPF at the CONCEPTUAL level before you even consider it.
In GDI / GDI+ you piece together / GUIs at the pixel level and it all gets drawn on a single surface / off screen DC / double buffered, etc.
No such concepts in Silverlight / WPF. You piece together GUIs at the OBJECT level (controls & shapes) and you end up with a LAYERED SURFACE.
In GDI you draw a rectangle on screen and then draw another rectangle on top... now you have a flat surface with no idea of whats there. Its just pixels.
In WPF / SL, they remain as layered objects so you can move / resize / show / hide / animate / rotate / etc.
In WPF / SL you do your GUI in pretty much all XAML and only do business logic in the code behind.
So in answer to your question, you don't port GDI code to SL, you dump it and rewrite in XAML .
|
|
|
|
|
This article may be an interesting read - http://niknak.org/blog/631-say-goodbye-to-gdi-on-the-web[^].
AFAIK. there is no automated tool that does this.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
|
Thanks for your samples and thaks to everybody. Very clear the different approaches GDI/Silverlight. OK I have to learn xaml and rewrite my gdi app.
But just a more question: In order to host on a web page a painting App like mine (drow lines, draw images, interact with mouse) and having to re-write the old App in another language/environment, is Silverlight the only right solution or may be Javascript or what else.
Having to experiment one more environment is Silverlight the winning solution?
I understand this is a very generic question, but may be you can help me with your experience.
Thanks
|
|
|
|
|
I have the following class
namespace WpfDataTemplate
{
public class Rung : UIElement
{
public int RungNumber { get; set; }
}
}
and the following XAML
<Window x:Class="WpfDataTemplate.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfDataTemplate"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<StackPanel.Resources>
<DataTemplate DataType="{x:Type local:Rung}">
<Grid VerticalAlignment="Top" MinHeight="60" MinWidth="175">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75"/>
<ColumnDefinition MinWidth="175"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="number" Text="{Binding RungNumber}"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Path x:Name="LeftRail" Data="M0,0 L0,60" Stretch="Fill" Stroke="Blue" Width="1" HorizontalAlignment="Left" Grid.Column="1"/>
<Path x:Name="RightRail" Data="M0,0 L0,60" Stretch="Fill" Stroke="Blue" Width="1" HorizontalAlignment="Right" Grid.Column="1" Margin="0,0,10,0" />
<Path x:Name="Run" Data="M0,0 L10,0" Height="1" Stretch="Fill" Stroke="Blue" Grid.Column="1" VerticalAlignment="Top" Margin="0,30,10,0"/>
</Grid>
</DataTemplate>
<local:Rung x:Key="newRung" />
</StackPanel.Resources>
<StackPanel Height="50" Orientation="Horizontal">
<Button Height="24" Content="Add Rung"/>
</StackPanel>
<ContentControl Content="{StaticResource newRung}"/>
</StackPanel>
</Window>
I want to add a click handler to the button that will add an instance of the class to the MainWindow, but it doesn't work.
private void Button_Click(object sender, RoutedEventArgs e)
{
Rung r = new Rung {RungNumber = 1};
RungSurface.Children.Add(r);
}
Can anyone help?
Thanks,
Jim
|
|
|
|
|
I can't see anywhere in the xaml where the RungSurface in bound.
"You get that on the big jobs."
|
|
|
|
|
I got confused with all the path stuff and the use of the local as a datacontext.
I would think he should change the underlying datacontext, presumably an observablecollection.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I must admit, there are so many ways to do things in xaml, I'm not sure myself but I would have expected something along the lines of:
<StackPanel ...>
<ItemsControl ItemsSource="{Binding RungSurface}"
"You get that on the big jobs."
|
|
|
|
|
I am using Silverlight 4.0. I'm trying to save a block of text to a txt file in Isolated Storage. However when the file reaches exactly 1000 characters, it stops loading and closes itself. Is 1000 characters the maximum file size for a file in isolated storage. What if I have about 5000 characters to store? Am I just missing a setting somewhere?
Thanks
Brent
|
|
|
|
|
|
But does 1000 characters take 1 megabyte to save? It actually takes 1 kilobyte.
My isolated storage variable says I have tons of free space.
The odd thing is that the stream writer doesn't throw an error.
Brent
|
|
|
|
|
Sorry, there was another unrelated error that was interrupting the stream flushing. Fixed it and now I'm getting my entire file.
Brent
|
|
|
|
|
Well. Thanks for posting the solution.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
The following line does not compile in silverlight 4.0
XmlDocument myFile = new XmlDocument();
Note that I do have a reference to system.xml and also using the
using System.Xml namespace
Any thoughts please?
Thanks
|
|
|
|
|
You can't really use XMLDocument.
What you need to do is use XDocument and do something like -
XDocument myFIle = XDocument.Parse(xmlContent);
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I agree that he should probably use the newer classes, he can still use XmlDocument that way if he wants to. See my answer to his question.
".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
|
|
|
|