|
Just try to understand MVVM rather than going through some code. Once you can understand MVVM, You will get to know how to do that.
|
|
|
|
|
Hi,
Please picture the below points (WPF-> WCF-> DataBase)
1. MVVM is an architecture design pattern used in WPF
2. WPF application need to consume a WCF service for performing CRUD operations
3. WCF will contain the logic for performing CRUD operations with Database for that you can use NHibernate, Entity Framework or with simple ADO.net etc
|
|
|
|
|
Good Day All
I have two WPF Pages Page 1 and Page 2. i want to change the a Label of Page 2 from Page 1.
tried to create an Instance of Page 2 in Page 1 and access the label and Change the content property before i explore the Property Solution if there is anyone who has a different solution. please help
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Hello Everyone
I'm struggling to solve the problem with my nested UserControl.
When I run the application the main window opens, inside the main window is a button, when I click that button it calls up a UserControl (called Applic).
Inside the Applic UserControl is another nested UserControl called PasswordScreen.
Within the PasswordScreen there is a button called Login, when I press this button to call another UserControl (called SwitchboardView) it is not firing nothing (here is the sample code)
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
Applic ap = new Applic();
SwitchboardView sbv = new SwitchboardView();
ap.MainGridApplic.Children.Add(sbv);
}
Could someone please help me solve this problem, I have been struggling for a long time to solve this problem but I just can't get it around.
Thanks in advance...
Kind regards
Roni
|
|
|
|
|
You have already posted this in QA[^]. You've been here long enough to know our opinion of reposts.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Roni,
I created a WPF with nested controls and its working fine, what i did was
Created 4 UserControls naming - UC1, UC2, UC3, UC4
As per the scenario stated in the question a UserControl is nested in another
The code is as below :-
UC1 XAML:-
<usercontrol x:class="TestWPF.Views.UC1"
="" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns ="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300">
<grid x:name="MainGrid">
UC1 CODE BEHIND:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.MainGrid.Children.Clear();
this.MainGrid.Children.Add(new UC2());
}
UC2 XAML:-
<usercontrol x:class="TestWPF.Views.UC2"
="" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns ="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" d:designheight="300" d:designwidth="300">
<grid x:name="MainGrid">
UC2 CODE BEHIND:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.MainGrid.Children.Clear();
this.MainGrid.Children.Add(new UC3());
}
Similary for UC3 and UC4
Try it let me if any problems
|
|
|
|
|
|
How to download a excel file in silverlight which is returned from wcf service in form of byte arrays ?
|
|
|
|
|
Sounds doable, so where are you stuck?
|
|
|
|
|
The content of Excel files is specific to Excel, and can only be converted by reading it via ODBC or Excel Interop.
|
|
|
|
|
|
OK, then please answer the question with the details rather than telling me this.
|
|
|
|
|
He didn't ask for something like that. His question makes no sense to me.
|
|
|
|
|
|
I just wanted to tell you for your own benefit (potentially) and clarify it for anyone else reading this thread.
|
|
|
|
|
Apart from saying that I am wrong you have not added anything that would be for anyone's benefit. Using the libraries that I suggested could (potentially) solve the OP's question.
|
|
|
|
|
Isn't it of anyones benefit who's interested to read/write Excel files to know that there are alternatives to ODBC/Interop!? Finding those libraries isn't hard work.
|
|
|
|
|
And you are certainly not going to help them.
|
|
|
|
|
|
So I took the code from a StackOverflow[^] question:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Image Name="Image" Source="TwitterBirdsAttack.jpg" MouseMove="Image_MouseMove" MouseUp="Rectangle_MouseLeftButtonUp" />
<Rectangle Name="Rect" Width="100" Height="100" Fill="Transparent" Stroke="Red" StrokeThickness="5" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp" />
</Grid>
</Window>
Class MainWindow
Private moveRect As Boolean
Private trans As TranslateTransform = Nothing
Private originalMousePosition As Point
Private Sub Rectangle_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
originalMousePosition = e.GetPosition(Image)
moveRect = True
Rect.IsHitTestVisible = False
End Sub
Private Sub Image_MouseMove(sender As Object, e As MouseEventArgs)
If moveRect Then
trans = TryCast(Rect.RenderTransform, TranslateTransform)
If trans Is Nothing Then
trans = New TranslateTransform()
Rect.RenderTransform = trans
End If
trans.Y = -(originalMousePosition.Y - e.GetPosition(Image).Y)
trans.X = -(originalMousePosition.X - e.GetPosition(Image).X)
End If
End Sub
Private Sub Rectangle_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
moveRect = False
Rect.IsHitTestVisible = True
End Sub
End Class
Now, the first time I move the rectangle it behaves as expected. But once its settled in its new location, it starts over again in its original location. It did not matter what I tried, the second time I clicked the moved rectangle its settled in the middle of the screen.
I tried saving the last Transformation and use this before mouse move was initiated in Rectangle_MouseLeftButtonDown, but that didn't do any good it simply refused to move.
I'll bet its something obvious that I have missed, but I cant see it now.
|
|
|
|
|
Jippi, I get to answer my own question. The problem is that you have to force it to remember the last position.
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Image Name="Image" Source="TwitterBirdsAttack.jpg" MouseMove="Image_MouseMove" MouseUp="Rectangle_MouseLeftButtonUp" />
<Rectangle Name="Rect" Width="100" Height="100" Fill="Transparent" Stroke="Red" StrokeThickness="5" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="trs" X="0" Y="0"/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Window>
The code behind:
Class MainWindow
Private moveRect As Boolean
Private trans As TranslateTransform = Nothing
Private originalMousePosition As Point
Private LastPos As New Point
Private Sub Rectangle_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs)
originalMousePosition = e.GetPosition(Image)
moveRect = True
Rect.IsHitTestVisible = False
End Sub
Private Sub Image_MouseMove(sender As Object, e As MouseEventArgs)
If moveRect Then
If LastPos <> Nothing Then
trs.Y = -(originalMousePosition.Y - e.GetPosition(Image).Y - LastPos.Y)
trs.X = -(originalMousePosition.X - e.GetPosition(Image).X - LastPos.X)
Else
trs.Y = -(originalMousePosition.Y - e.GetPosition(Image).Y)
trs.X = -(originalMousePosition.X - e.GetPosition(Image).X)
End If
End If
End Sub
Private Sub Rectangle_MouseLeftButtonUp(sender As Object, e As MouseButtonEventArgs)
moveRect = False
Rect.IsHitTestVisible = True
LastPos.X = trs.X
LastPos.Y = trs.Y
End Sub
End Class
|
|
|
|
|
hi
in part of my WPF Application I need something like a day of calendar that has from up 00:00 to down 23:59 and I need to drag and drop the songs on it to get play in specific time. like a play list.
that's in my mind and I need to know how can I create that calendar day.
what kind of controls should I use? is there some code sample to help me to get some idea?
thanks
|
|
|
|
|
Rather than use a calendar control, which is a rather heavy duty object with lots of stuff around appointments etc, I would use a listbox or a treelistview which are much simpler collection controls.
I presume you do not need the appointment functionality.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
Please suggest me any way to achieve this functionality. I have one textbox1, when I enter any value to this textbox1 then it should update to other textboxes i.e. textbox2, textbox3, textbox4, textbox5.....
|
|
|
|
|
You need to use the ElementName property of the Binding :
Binding.ElementName Property[^]
WPF Data Binding - Part 1[^]
<StackPanel>
<TextBox Name="textBox1" />
<TextBox Name="textBox2" Text="{Binding ElementName=textBox1, Path=Text}" />
<TextBox Name="textBox3" Text="{Binding ElementName=textBox1, Path=Text}" />
<TextBox Name="textBox4" Text="{Binding ElementName=textBox1, Path=Text}" />
<TextBox Name="textBox5" Text="{Binding ElementName=textBox1, Path=Text}" />
</StackPanel>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|