views:

381

answers:

1

Hi all,

I've recently been playing around with the awesome Twitterizer Twitter API using C# WPF in Visual Studio 2008. It's been working the most part, but I do have some questions about it.

1) How can I make it so that the login screen is a different windows that closes when you log in, unless there is a login failure?

2) How can I make it so that it tells the user that their login information is incorrect?

3) How can I make it save the user's login information so that they don't have to enter again?

4) How can I make a character countdown when a user is posting a status and not let it be posted if it is over 140 characters?

Sorry if these questions seem kind of noobish. i'm not very good at C#, especially since this is my first time using the WPF framework.

+1  A: 

This is several questions. You should ask them separately.

How to make Login a different window

Add a new Window to your project. Implement your login screen there. Show the new window when the app starts up (or whenever it is appropriate to do so).

How to display login error messages

When the "Log in" button is clicked in the window, execute the login. If it fails (you get an exception), display a dialog box, otherwise close the login window.

How to save the user's login information

You should save such information to the protected store instead of writing it to a file. Save it after a successful login. Load it when the application starts.

How to make a character countdown

Add a new "CharactersLeft" dependency property to your user control or window. Add a PropertyChangedCallback to your Text property (I assume you have one - it should be a DependencyProperty as well and your TextBox should be bound to it). In the PropetyChangedCallback, update the CharactersLeft value. Bind a TextBlock to the CharactersLeft value.

How to prevent posting if CharactersLeft is negative

If you are using an ICommand, implement CanExecute. If you are using a RoutedCommand, implement OnCanExecute. If you are directly handling the button click, consider using commands instead, or set a trigger on your button button so that it becomes disabled whenever CharactersLeft is less than zero. (You will need a IValueConverter for this, or you can just have a separate property.)

Ray Burns
thank you so much! That's about all the help I need.
David