Silverlight Voting Control

June 29, 2009 10:57 by John M
Ok so this is a very simple Silverlight 2 voting control that I worked on to learn how to do a few things in Silverlight.  I will be making a Silverlight 3 version once it is officially released.  I guess some would call this a silverlight polling control as well.  I don't know, I'm calling it a voting control.  So here is what it was designed in:

  • Silverlight 2.0
  • ASP.NET 3.5 site hosting the Silverlight control
  • Visual Studio 2008

Here are the concepts involved in the control:

  • Read an XML file via the WebClient using the OpenReadAsync method
  • Write an XML file via the WebClient using the UploadStringAsync method
  • LINQ to XML
  • The Charting Control using the Bar Series.

Here are some notes about the control.

  • It is not very fancy so please style it how you please.  I personally took out the legend on the BarSeries because it allows for more room.  
  • It does not have any sort of management interface to edit the XML file.
  • Give the PollData directory in the Web Project write access
  • fileUploader.ashx in the Web Project handles writing the file back to PollData (could use some more error catching
  • Dimensions are 350 x 345
  • FileUri and FileUploaderUri paths are in the App.xaml
  • The XML file contains the question and title as part of the root attributes


Here are some screenshots of what it looks like





The full source code is attached so feel free to do whatever it is you like.  

Source Code

TestSLSurveyPoll.zip (1.16 mb)


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Grouping RadioButtons in Silverlight ListBox

June 26, 2009 08:39 by John M
I was working on a simple voting control in silverlight and ran into a problem that I couldn't figure out how to solve. Coming from an ASP.NET background, I keep wanting to learn silverlight more and more and see how it can fit into the business world.  For those of you that read this blog you know the few things I have done in Silverlight have to do with multimedia.  Anyway... so here was my problem

I wanted to group RadioButtons in a ListBox.  Simple enough right?  Well this ListBox was going to use binding and not be static with items in it.  It was reading data from an XML file and using a DataTemplate to create however many RadioButtons I needed in the ListBox.  Below is the code I was using.

--------------------------------------
XAML:

<ListBox x:Name="listVotingOptions">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <RadioButton Content="{Binding Option}" GroupName="votingGroup" Tag="{Binding ID}"></RadioButton>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>


Code Behind:

//....code here for var results = blah blah blah

listVotingOptions.ItemsSource = results.ToList();

--------------------------------------


Looks like it would work. However, it doesn't. Here was best I found on it searching the Internet.

http://stackoverflow.com/questions/170061/is-there-a-way-to-group-radiobuttons-generated-from-the-itemtemplate-of-an-itemsc

Now I understand I'm not a Silverlight expert, but it has to do something with the logical tree as explained in the link above.  I took some time and used the VisualTreeHelper and noticed that the listbox did not have anything that contained RadioButtons.  If any of you can shed some more light onto why this is that would be greatly appreciated :)

The link above also contains a link with someone who got it to work via Behaviors.


Note: This is a great page for learning how to use a listbox in silverlight:

http://blogs.msdn.com/delay/archive/2008/03/05/lb-sv-faq-examples-notes-tips-and-more-for-silverlight-2-beta-1-s-listbox-and-scrollviewer-controls.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: Silverlight
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

NETOOP - .NET Object Oriented Portal

June 16, 2009 08:39 by John M

 

UPDATE: 06-22-2009

Forgot to mention you can use the hashtag #NETOOP to follow on twitter. 

 

I am participating in the following community project (name above).  The project is going to an open source sports community portal.  The project will actually be built by Joe Stagner, but he wants the community to help him with the design process.  It's in the early stages, but my name in the wiki and forums is johnmendez00.  Here is a link to the project itself

http://misfitgeek.com/blog/aspnet/introducing-netoop-the-net-object-oriented-portal/

 


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Callout Balloon in Silverlight

June 2, 2009 08:12 by John M
So since I'm not a designer by any means, I needed a way to create a balloon callout for my silverlight application.  This XAML below will work in Expression Blend 2 or Expression Blend 3 Preview to create a callout balloon in Silverlight. The main concept is as follows:

1. Use a canvas as the container for the callout balloon
2. Use a rounded rectangle for the main area to hold content in the balloon callout
3. Use a path to create the triangle portion of the callout
4. Use a line to cover the border of the rectangle where it overlays the triangle created by the path


The image below is what results from the code.


<Canvas Margin="95.5,112,169,88" x:Name="canPopOutDesc">
            <Path Height="44.314" Width="35.571" Canvas.Left="2.726" Canvas.Top="92.137" Stretch="Fill" Stroke="#FF000000" StrokeThickness="1" Opacity="0.595" Data="M97.22541,215.14671 L131.79651,171.83289 L130.92891,209.81383 z" x:Name="pathPopOutTriag">
                <Path.Fill>
                    <LinearGradientBrush EndPoint="-0.566,0.528" StartPoint="1.502,0.523">
                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                        <GradientStop Color="#FFCAC2C2" Offset="0.364"/>
                        <GradientStop Color="#FFFFFFFF" Offset="1"/>
                    </LinearGradientBrush>
                </Path.Fill>
            </Path>
            <Rectangle Height="200" Width="100" Canvas.Left="33" RadiusX="10" RadiusY="10" Stroke="#FF000000" StrokeThickness="0.5" Opacity="1" x:Name="rectPopoutDescHolder">
                <Rectangle.Fill>
                    <LinearGradientBrush EndPoint="-0.566,0.528" StartPoint="1.502,0.523">
                        <GradientStop Color="#FFFFFFFF" Offset="0"/>
                        <GradientStop Color="#FFCAC2C2" Offset="1"/>
                        <GradientStop Color="#FFFFFAFA" Offset="0.467"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>
            <TextBlock Text="this is some text people for a description of some sort" TextWrapping="Wrap" FontSize="9" x:Name="txtPopupVidDescription" Width="86" Height="185" Canvas.Top="7" Canvas.Left="40"/>
            <Path HorizontalAlignment="Left" Width="1" Stretch="Fill" StrokeThickness="1" Data="M129,174.5 L129,205.52274" Fill="{x:Null}" x:Name="pathPopOutLine" VerticalAlignment="Bottom" Height="33" Canvas.Top="99" Canvas.Left="33">
                <Path.Stroke>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="#FFE5DFDF" Offset="0"/>
                        <GradientStop Color="#FFE0DCDC" Offset="1"/>
                        <GradientStop Color="#FFE0DCDC" Offset="0.764"/>
                    </LinearGradientBrush>
                </Path.Stroke>
            </Path>
        </Canvas>



Now there may be an easier way to accomplish this, but then again I'm not a designer so please let me know if there is so I know for the future :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: Silverlight
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

LINQ Good or Bad?

May 22, 2009 07:51 by John M
Now that I have had a chance to work with LINQ a little more I just wanted to express my opinion on how I think it can a bit of a downfall for a developer. Don't get me wrong I think LINQ is such an awesome development concept.  For me personally, I will try to never work with XML again without LINQ in a .NET application. Now saying that, I think LINQ takes away some important concepts a developer must know.  

For those just starting out and are a bit new to development, those people may not know how to use an XML file or query a SQL database without LINQ.  I see this as a disadvantage, as I feel knowing what is happening on the underlying layer is very beneficial for ones knowledge.  Knowing this allows developers to troubleshoot their app more efficiently and effectively.  I couldn't imagine not knowing T-SQL, but if I was new to .NET why would I care to know it as well as I do now with LINQ available to me?  

I think all developers should know T-SQL (or any sQL language for that matter) well enough to make decent stored procedures,  triggers, views, and scalar/table functions.  I personally feel the more I can get done on the database side the easier my .NET code is to write and easier for others to read.  Why put logic into a .NET app if it doesn't need to be there? This allows for less maintance on the app itself and more on the database side (which has seemed to work well in most cases I've been involved with).

Also with XML, I think all developers should know how to traverse and query an XML document without LINQ.  Because maybe a solution to a problem one day will not involve .NET, but it does involve XML from one source or another.  If you don't know how to work with XML without LINQ, you just put yourself in that much more difficult of a situation.

As a developer your attitude should be to gather more skills and concepts and add them to your pool of knowledge instead of relying on certain ideas/methods to get you by at all times.  I just want to get this out there for those just starting and don't forget about the basics and underlying concepts of what makes an application work.  Yes LINQ is there to make your job easier, but please know how to get something done without it as well. If anything, know the concept of how to get something done without LINQ.  

Even having said this...I love LINQ! (especially with collections)

Thanks for putting up with my rambling!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Categories: General
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed