|
A good thing to do right now would be to buy a decent book. I had C# 3.0 in a Nutshell and WPF Unleashed practically stapled to my person for a good year and a half. The C# 3.0 book is really great as it is very informative and concise in it's explanations and whenever digging into something it gradually introduces the complexities rather that starting with them.
Sounds to me like you need to explore a number of big topics to get this app completed. Stuff like N-Teir/SOA architecture, WCF (Web services), LINQ or the Entity Framework for data access layer (interaction with SQL Server) as well as C# / WPF. This is a lot to go for at once.
I think it might be a good idea to start with smaller portions of stuff to begin with. Have you used Test Driven.NET? Since you have the full blown VS 2008 you can use plugins.
Go and grab a copy of http://www.testdriven.net/[^] and install it. Then create a basic class library and write some unit tests. This will provide you a really nice environment to learn in. TTD.NET will allow you to write a unit test in C# and simply right click it to run the code (with or without the debugger attached). I personally love this combination as it's a really fast way to play with code.
This will also get you into a good habit of writing tests to either prove your code works or drive the development process itself.
The datagrid stuff you talk about doing is fairly straight forward but I woould cover off some simpler WPF data template / styles stuff before leaping into that just yet.
|
|
|
|
|
Hello all,
I'm fairly new to Silverlight and MVVM and I'm struggling with the correct way of doing the simple task of changing the top level silverlight view. Using Silverlight 4 commanding I am binding a command on my view model to a login button on my main form and then calling an authentication service to ensure the credentials are valid, this is working and I can authenticate the user. What I am struggling with is the best way of closing the login screen and displaying another screen when I get a successful response from my service. From what I understand you cannot hook a callback event in the view to a command object and I should also be trying to avoid having any code behind in the view so where do I control the opening of a new view? Obviously, my ViewModel should know nothing about the view so I can't do it there, can I?
The way I was going to approach it is still use the button bound to a command on the view model but use a bit of code in the view to hook an event to the view model which is fired when I get the successful login from the service. The event hooked up in the view would then control switching the views but from the examples I have looked at I am not convinced this is the best way forward.
Am I missing something obvious or looking at the problem in completely the wrong way?
I'm hopeful this question will have a straight forward answer but after hours of browing examples on the web I'm still none the wiser as to the correct approach.
|
|
|
|
|
DoctorMick wrote: Obviously, my ViewModel should know nothing about the view so I can't do it there, can I?
There could be a few ways to handle this.
An easy approach would be to use the navigational framework. But this does not provide the decoupling you are talking about.
You cannot let your viewmodel know about the new view that you would want to launch, but you can let it know about the viewmodel for it. Create an instance of the view using the viewmodel. All this is based on the assumption that you are using the "viewmodel first" approach while implementing MVVM.
If you want to decouple a little more than that, use a common controller class that handles all view / view model creations - this way all your view model knows about is this common controller class - nothing else.
A fourth approach could be to use the EventAggregator pattern implemented by Microsoft Prism. Prism provides very high level of decoupling, but then there is a learning curve attached to the features it provides.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Dear friends
i have an issue .. i am new to WPF,
my requirement is to (binding "custom property" for user control)
can some one point out my mistake?
User Control
-------------
<Grid >
<TextBlock Name="textBlock1" Height="28" VerticalAlignment="Top" Background="AliceBlue"/>
</Grid>
UserControl Code behind
--------------------------
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));
int nType =0;
public int CoType
{
get {return nType;}
set {
nType =value;
textBlock1.Text = value.ToString();
}
}
static void textChangedCallBack(DependencyObject property,DependencyPropertyChangedEventArgs args)
{
UserControl1 searchTextBox = (UserControl1)property;
searchTextBox.CoType = (int)args.NewValue;
}
}
Main Form
-----------
<Grid>
<uc:UserControl1 CoType="{Binding CoTypeValue}"/>
</Grid>
Main Form Code behind is just InitializeComponent()
ViewModel
--------------
public int CoTypeValue
{
get { return nV; }
set {
if (value != nV)
{
nV = value;
OnPropertyChanged("CType");
}
}
}
The Error message i recive
Cannot create instance of 'UserControl1' defined in assembly 'WpfModelViewApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error at object 'System.Windows.Controls.Grid' in markup file
If i remove the Dependency property .. the error is not thrown .. but i want to binding for custom property.. and i not sure about the way i have implemented binding for custom property is the right way..
any help????
|
|
|
|
|
I have doubt with line:
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new UIPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));
As per my knowledge UIPropertyMetadata is mainly used for provide animation behavioure. I would suggest try with FrameworkPropertyMetaData for databinding purpose.
Just try on your side if still it is not working then I will look into that.
http://msdn.microsoft.com/en-us/library/ms751554.aspx[^]
Thanks for your patience!
Parwej Ahamad
ahamad.parwej@gmail.com
modified on Tuesday, March 30, 2010 9:53 AM
|
|
|
|
|
Dear friend
Thanks for your reply ,
i have changed those lines as
public static readonly DependencyProperty coProperty = DependencyProperty.Register("CoType", typeof(int), typeof(UserControl1),
new FrameworkPropertyMetadata(string.Empty, new PropertyChangedCallback(textChangedCallBack)));
but no use, if you have already done some samples on Custom Property ..please send it to i.joerozario@gmail.com other wise i will send my sample source.. if u correct that would be great help for me..
Thank you
|
|
|
|
|
Please send me your sample code on ahamad.parwej@gmail.com.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
Hi Joe, I catch one more thing here you are not using Setter and Getter method:
public int CoType
{
get {return nType;}
set {
nType =value;
textBlock1.Text = value.ToString();
}
}
Should be like:
public int CoType
{
get { return (int)GetValue(coProperty ); }
set { SetValue(coProperty , value); }
}
Change your code and let me know.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
Basic sample sent on your personal ID.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
Dear Ahamad
Thanks for everything..
i found my mistake.
in the Usercontrol1.xaml i did not bind the text like
Text="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type local:UserControl1}},
Path=CoType}"
Thank you
by
Joe
|
|
|
|
|
I don't know exactly why you got this error message, but your "dependency property" is NOT a properly declared and used dependency property!
use the "propdp" snippet in VS to declare one
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I.
I'm building a Silverlight Interface and suddenly every time i try to save the project,a window is shown saying:
"C:\Users\Documents\Visual Studio 2008\projects\MyProject\MyProject\obj\debug\mainpage.g.cs.
This File was changed out of the source code text editor.
Do you wish Reload it?
|Yes| |Yes to all files| |No| |None|".
I would like to Know why this happened and how can i fix it.
Thanks very much.(Excuse my english but i'm trying the best to make my self clear )
Jonatan regards
|
|
|
|
|
Try doing a "clean solution" and save again.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hello.
I had already tried to clean the solution and the problem subsisted. I fix it by deleting the obj folder where the mainpage.g.cs is stored.
Thanks any way for the tip.
regards jonatan.
|
|
|
|
|
jonatan_556 wrote: I fix it by deleting the obj folder where the mainpage.g.cs is stored.
Great .
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Hi, I want to create a MDI application in WPF which will contain some "x" tabs each having their own set of controls such as "Text boxes", "Combo boxes", "IP Address control" etc.
The no of tabs and the list of controls to be displayed in each tab are available in a XML file.
How to implement this?
Any help on this is highly appreciated.
|
|
|
|
|
In the mean time I am giving here steps. If you stuck anywhere then free to ask here. Thanks.
Step: 1- Arrange all data into XML properly. I am assuming each item having it's all required information.
Step: 2-
Crate a class contais that contains all required properties which can contain the XML item data.
Step: 3-
Load all XML tab item data using Linq in Generic list (Like: List<tabliteminfo>)
XDocument xmlDoc = XDocument.Load("TabItemsData.xml");
List<TabItemInfo> tabItemInfoList= (from tabItem in xmlDoc.Descendants("TabItems")
select new TabItemInfo
{
TabItemID =int.Parse(tabItem.Element("TabItemId").Value),
TabName = tabItem.Element("TabName").Value,
}).ToList<TabItemInfo>();
Step: 4-
On WPF window. Creat a Tabcontrol without any tabitem.
Note: No need to take Tabcontrol at design time. You can also take at runtime and add it into Grid or Stack Panel whatever panel are using.
Load all controls items as tab item.
foreach (TabItemInfo tabItemInfo in tabItemInfoList)
{
TabItem tabItem = new TabItem();
tabItem.Header = tabItemInfo.TabName;
moduleTabControls.Items.Add(tabItem);
}
Hope so it will help you.
Thanks for your patience
Parwej Ahamad
ahamad.parwej@gmail.com
modified on Tuesday, March 30, 2010 11:18 PM
|
|
|
|
|
Thanks Parwej. I will try this and let you know.
|
|
|
|
|
Dear friends
i have some clarification
i have Image in xaml ... i want to bind command for "double click" of the image ..
and i have the command in my view model.. how to do that?
can some one give me with example
thank you
|
|
|
|
|
Have a read of this thread[^]. You need an InputBinding, and this explains what you need to do.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You can use a behavior or dependency property for double click instead of command.
|
|
|
|
|
Hi all,
I am new to the WPF arena and am trying to get started. I have created a simple winform containing a treeview and an elementhost containing my XAML. The XAML contains a textbox. When I select a node in the treeview I want to pass the node name to the textbox.
Everything is running fine but I do not know how to reference the controls within an XAML from the hosting winform. Any ideas, pointers, references I can look at?
|
|
|
|
|
Use this code:
Text="{Binding ElementName=treeViewControlID,
Path=SelectedNode.Text}"
I am not sure "SelectedNode.Text" is available but it may be kind of property. If it is not workable then post here.
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
You can samply convert the child control to TextBox. Try this:
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
System.Windows.Controls.TextBox tb = (System.Windows.Controls.TextBox)(elementHost1.Child);
tb.Text = e.Node.Name;
}
modified 27-May-14 4:38am.
|
|
|
|
|
i want to animate the ListBoxItem while Scrolling. Any body have any Idea How i can do it Plz plz Give me some hints;
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|