Code:Title="Window1" Height="300" Width="300" AllowsTransparency="True" Opacity="0.85" WindowStyle="None">
Printable View
Code:Title="Window1" Height="300" Width="300" AllowsTransparency="True" Opacity="0.85" WindowStyle="None">
That works
Yeah but I dont want to have a windowstyle of "none" - I dont see how VB.NET can make windows transparent easily enough but the great graphical user interface product WPF cannot :S
Anyway I'm going to bed now, I have to be at work in 5 hours :(
Just noticed a link to this article at the top of the forums
http://www.devx.com/dotnet/Article/4...k=DXRSS_DOTNET
Quite good for people like myself who are pretty new to the whole WPF thing :)
Hey man, ok I think the difference in the transparency is because WPF is true transparency where as Winforms is only pseudo transparency, il find out more later. PS good article, im going to put that in my sig, it will save me writing one up. Also dont panic im only a beginner too! I just have a head start!
One feature I played with recently was with the templates concept.... puts a whole new spin on things... I was able to make a list box.... the standard WPF listbox... contain multi-lined items, with a blue header for the first line and rounded corners.... If I had thought about it sooner I would have grabbed the sample from home to post it. It was pretty cool and surprisingly easy to do. And didn't require all sorts of inheriting and subclassing and ownerdrawn this and ownerdrawn that.... jsut some simple XAML tags and attributes.
-tg
Yeah its pretty funky, im working on a validation text box who's border will "pulse" red if the data is incorrect. with rounded corners too! I lover rounded conrners! Everything should have rounded corners!
I love rounded corners too... three cheers for rounded corners!
PS how do you make them in WPF?
I'd say that I'll look for the code tonight, but it's the wife's bday and we're going out. If I remember tomorrow or in the middle of the night, I'll post it.
But it wasnt' that hard... takes like three attribute properties, a color, a margin and a style, if I remember right.
look in the WPF How To video section on MSDN... I think that's where I got it from.
-tg
cool I will take a look at the WPF vids :)
Chris, how are you getting on? I cant do a lot of coding until monday unfortunately but I have been playing with silverlight. Are you a convert yet?
Actually separating the UI from the rest of the program is a design of n-tier.Quote:
Originally Posted by chris128
An example...
UI
Business Rules
Data Layer
Database
So separating the UI from the business rules and even other apps like Fat Clients can have big improvements in many areas if separated.
I'm struggling to get ListViews to work the way I want them to as the ListViewItem class doesnt seem to have the same properties that it has in winforms .NET :(Quote:
Originally Posted by DeanMc
Basically I want to display some info in a datagridview style and as there is no DGV control for WPF I am trying to use a ListView to do it but all of the examples seem to be using DataBound controls and I dont ever use data binding...
I'll post a new thread in the VB.NET section about this to see if anyone can help
But wasn't he whinging about the "code behind" concept here?Quote:
Originally Posted by RobDog888
We keep hearing about how liberal arts majors will whip up the UI and then troglodyte programmers will add code "behind" that. Farce!
Just to start with you end up dealing with UI elements with default names created by the GUI designer tool (bleh). I also can't see how one can create the "form" of an application with little concept of its "function."
And as stated (maybe overstated) above, much of the time you need to micromanage the UI elements in code to get the required behavior anyway. At least I seem to see lots of code and questions here indicating that default control behaviors just aren't enough for many people.
However I have no quarrel with tier separation. I think a lot of people here only write monolithic single user desktop applets though. They may never have had to deal with the kinds scalability and information security issues tiering addresses.
You might have a hard sell among those folks. It can be a bit like explaining color to a blind person.
I have to disagree, while any level of separation will result in more code, it does tend to be more elegant and I need not bother reiterating the pros of uncoupling the UI from the rest of the application as you understand that well enough.
As for your "Farce" statement, blend only requires a knowledge of Xamal not a programming language, even hooking up events is done in Xamal so yes arts majors could very well be making UI's.
The idea of WPF "IS" to enable UI creation without knowledge of function. The artist will simply be told the type of data and they will be in charge of presentation. Most artists present information many times better than programmers.
WPF is not only about artists. It is merely a move away from the new and will most likely evolve from where it is now very fast.
All controls are designed to be stateless so the default behaviour is irrelevant and also the included controls are PURE .net controls (not win32 hooks). I cant see how you find micromanaging themes irksome compared to sticking 3 or 4 controls together and pretending they are a new control.
The fact of the matter is WPF allows proper control creation as opposed to current custom controls which are mostly just elegant hacks built on an aging system.
Chris, data is much more powerful in WPF than before. They have changed how data is used, retrieved and displayed from a database. I really suggest this book as it is the best source so far.
Sorry not statless, controls are lookless, they just have a default look.
Well dean I have to say so far I am not impressed! lol see here: http://www.vbforums.com/showthread.php?t=554097
All that just to stick some items into a listview :( and god knows how I am actually going to refer to each of those items from code when I want to actually do something with them lol maybe I should read that book you mentioned first :)
Sorry man im in work so only seen this now. First off WPF datagrid and some other pure.net conrols: http://www.codeplex.com/wpf/Release/...eleaseId=15598
Secondly the ebook i have for you will help you out with data access. Also because all controls are lookless you will see that a templated listbox will be just as good (if not better!)
When you see how templates function lookless controls will also make more sense.
Il be home later and pass that ebook on to you!
OK cool cheers :) I'll see if it all makes more sense then
grrrr just spent 35 mins trying to get a simple timer to work! Why the hell have they removed the ability to add components from the toolbox :( It makes using things like timers and backgroundworkers an awful lot more work...
Timers are not in the control box for WPF, what do you need a timer for?
I hate adding times via the designer. It's just not natural... in my opinion, anyway.
What about BackGroundWorkers then? Do you add them just through code and hook up all the events yourself? Because thats what you have to do in WPF...Quote:
Originally Posted by Kasracer
Im with Kas on this one chris, I tend to hook most things up in code
So, this is a test of course but it is basicly the style I will be using for a notes application:
http://img26.picoodle.com/img/img26/...rm_9031721.jpg
Ah-ha! I finally found it.... sorry it took me so long.... but here's how to get a listbox to have multi lined items and rounded corners.
First the XAML:
The "data" class:Code:<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
<Grid>
<ListBox x:Name="lstItems" Width="200" MaxHeight="300" FontSize="16" Background="Blue" >
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" Background="White" Margin="4,4,4,4" BorderThickness="1" CornerRadius="5" Width="150">
<StackPanel Orientation="Vertical" Margin="3,0,3,0">
<StackPanel Orientation="Horizontal" Background="AntiqueWhite">
<TextBlock FontSize="16" Text="{Binding Path=FirstName}" />
<TextBlock FontSize="16" Text=" " />
<TextBlock FontSize="16" Text="{Binding Path=LastName}" />
</StackPanel>
<TextBlock FontSize="12" Text="{Binding Path=Age}" />
<TextBlock FontSize="12" Text="{Binding Path=FavoriteMovie}" />
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
And then the code to load into the list box:Code:Public Class MyPeopleData
Private _lastName As String
Private _firstName As String
Private _age As String
Private _favoriteMovie As String
Public Sub New(ByVal firstName As String, ByVal lastName As String, ByVal age As Int32, ByVal favoriteMovie As String)
Me.FirstName = firstName
Me.LastName = lastName
Me.Age = age
Me.FavoriteMovie = favoriteMovie
End Sub
Public Property LastName() As String
Get
Return _lastName
End Get
Set(ByVal value As String)
_lastName = value
End Set
End Property
Public Property FirstName() As String
Get
Return _firstName
End Get
Set(ByVal value As String)
_firstName = value
End Set
End Property
Public Property Age() As String
Get
Return _age
End Get
Set(ByVal value As String)
_age = value
End Set
End Property
Public Property FavoriteMovie() As String
Get
Return _favoriteMovie
End Get
Set(ByVal value As String)
_favoriteMovie = value
End Set
End Property
End Class
In XAML it's the CornerRadius attribute that controls the rounded corners... as an FYI - I had to play wit the CornerRadius and the Margin attributes to get it to look somewhat right... the original code I had copied didn't allow enough room between the edge and the data, so the left side was rounded, but the right got squared off... increasing to the top margin dropped the data down just enough to get the rounds on both sides.Code:Class Window1
Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
lstItems.Items.Add(New MyPeopleData("Han", "Solo", 45, "Star Wars"))
lstItems.Items.Add(New MyPeopleData("James", "Kirk", 36, "Star Trek"))
lstItems.Items.Add(New MyPeopleData("Martha", "Jones", 24, "Dr. Who"))
lstItems.Items.Add(New MyPeopleData("Will", "Smith", 32, "Independence Day"))
lstItems.Items.Add(New MyPeopleData("Christian", "Bale", 40, "The Dark Knight"))
lstItems.Items.Add(New MyPeopleData("Hugh", "Jackman", 46, "Wolverine"))
End Sub
End Class
-tg
Very Nice!
The more I play with it, the more I'm liking it.... I think my next project will be done in WPF.... don't know what it will be just yet, but I've got a couple of things I've been tossing about in my head... Might be a good opportunity to have a good go at WPF.
-tg
Im starting a simple information manager application, Its going to look like a standard windows application then im going to post videos on how to pretty it up!
I've still got my animation trigger problem :( I posted on the official MSDN WPF forum and so far no one on there seems to have any idea either...Seems odd as I thought it would be a very common thing to want to do :S
Well I finally got it working, so here's the solution for anyone else having the same problem (as there doesnt seem to be much on google about it, apart from for Silverlight but that requires a different solution)
That reminds me, isnt it time we had a WPF forum section on here :D This isnt really the place to post a solution to a WPF problem but I dont know where else to put it lol
Problem
You have created a StoryBoard animation either in Blend or just by typing it out in the XAML code view. You want to start this StoryBoard manually from your code-behind file (check me out with my correct terminology).
Solution
As the StoryBoard is actually declared in the Window.Resources part of the XAML code (or at least it is when you use Blend to create it) you can use the TryFindResources function to return your StoryBoard object by passing it the Key attribute of the StoryBoard. So say you named your StoryBoard "TestSB" in Blend, this is how you could start it in your WPF code-behind:
Obviously error checking etc would be needed but thats the basic idea. Hope it saves someone some time!vb.net Code:
Dim MyStoryBoard As StoryBoard = TryFindResource("TestSB") MyStoryBoard.Begin()
I agree, especially since WPF is language agnostic... it would be nice to have a WPF section....Quote:
That reminds me, isnt it time we had a WPF forum section on here This isnt really the place to post a solution to a WPF problem but I dont know where else to put it lol
I'll put in a request in the Forum feedback...
-tg
I already did a few months ago and wasnt told it wasnt popular enough I think, but maybe now it is? Now that 3 of us are trying to use it :P haha
Another handy thing that just took me ages to find out is that you can hook up an event to handle the Completed event of a StoryBoard so that you know when an animation has finished. Very useful if you are using an animation to exit a form (fade out etc). I'm not used to all this manual event hooking up stuff and have to say it does feel like we have kind of taken a step backwards instead of forwards as a lot of people (like myself) relied quite heavily on the designer to generate event handlers etc for us. I guess its teaching me things that will come in handy in general .NET antics but thats not the point really lol
Well if you post it I will second it techgnome. Chris you should always hook up your event handlers in code if you ask me that means you get a feel for its parameters when writing custom handlers.
Just wanted to post a little feedback on this 5 months down the line... basically to sum up: I now use WPF for all of my projects and would not go back to winforms unless I absolutely had to :) As you have all seen with this thread, there are a lot of things to get used to when you first move from winforms to WPF but once you get over the initial stumbling blocks and get your head around things then life is sweet. Well... not sweet, I still have the odd WPF related problem but most of the time I can just do whatever I want without a problem and I have so much more flexibility than I would have in winforms in terms of the UI.
As Dean pointed out earlier in this thread though, WPF is not just all about the UI, it has improvements in many other areas and I think everyone should at least give it a chance, especially when .NET 4 comes out and they fix the damn blurry text issue (which is probably the worst thing about WPF in my opinion) :D
I wish I had your confidence chris. I've tried WPF about 4 times now and I also keep stumbling on the dumbest things. My problem, is that the UI of all my applications are highly intelligent. They won't let you put in bad information, or have any button lit up when all the conditions of it's usage aren't met. I've tried hard to reproduce some of this behavior with WPF but keep falling on my face.
Also, as I think you even mentioned earlier, I hate the "XML" style of programming. My eyes go cross looking at all those Greater-Than/Less-Than marks. It made sense for HTML a many moons ago when a web page was 80% text and 20% code tags, but these days, pages are 95% code tags and 5% actual text, with things like XML and XAML being more in the 98%-2% range... It's like me putting all my program lines in VB.NET in double-quotes, and only actual strings would have no quotes around them. :mad:
Syntax-wise, I'm of strong opinion the majority of programming language's program code should be plain-text and only special conditions such as specific data-types warrant whole-line modifiers such as [brackets], <tags>, or "quotes".
Finally, I'm also totally for the idea that the end-user should have skin-control over all his programs, regardless of the program; and that means adherence to themes. When I launch 10 different applications, I DON'T want 10 different styles of buttons! I want them all to have the button style I chose for them to have in accordance with the theme I picked for the OS. I handle more problem calls these days because of inconsistent interfaces on programs than I ever have in the past. I'm sure there will be custom user-controls and custom behaviors of standard controls to fit circumstances, and that's fine, as long as they adhere to theme standards.
WPF sounds like a great system, but I'm still of the opinion it needs to be wrangled under control before any kind of widespread adoption. Maybe after my current project, I'll try WPF once again and find yet another set of tutorials for Design/Blend. I'll look for this mysterious superior functionality that's not only supposed to be as quick and easy to use as Winforms, but totally customizable and more feature laden as well.
Anyways, just my 2 cents on the matter.
Yeah thats fair enough and as you know I was exactly the same, I despised WPF for quite a while and gave it several 'goes' but they all ended with me being very frustrated. I also totally hated XAML but to be honest now I love it, I very rarely drag and drop anything from the toolbox... seriously if I want a new button I just type <Button Content="Click Me" Margin="2" /> and I'm pretty much done. One reason for this is because dragging and dropping controls from the toolbox with WPF just results in disaster because VS positions everything by setting the Margin property to ridiculous amounts and then when you add another control or move your control into another container etc it all goes to sh*t... so I guess that might be why I type XAML instead but I actually prefer it anyway now.
A recent example where I found WPF much easier than winforms is when making a custom error message box. Here's an example of the end result:
http://www.vbforums.com/images/ieimages/2009/05/1.jpg
To make that in winforms, whilst it certainly wouldnt be impossible, I believe it would involve a lot of measuring of strings etc to make sure each area (and the form) was big enough to fit all of the text in all of the time etc but with WPF I just simply set the TextBlock's TextWrap property to Wrap and create a couple of grids and stack panels and it all automatically lays itself out the way its supposed to every time with no code at all. Also when I created a custom messagebox window, to get the OK button to always be in the middle of the window no matter how wide the window is I simply set the HorizontalAlignment property to Centered like so: <Button Name="OkBtn" Content="OK" HorizontalAlignment="Centered" /> and thats it.
Also, just in case you didnt know, VS 2010 was made with WPF :) so you cant say its not really useable yet :P (although I admit it does still have its problems)