|
Thanks for your post that addresses my original issue. You caught me in the middle of getting stuff to work with the original Application.Current location. Maybe when I fully investigate your suggestion, I'll be backing out a lot of that code. But I have to take my current direction to its completion first (it's going to take another hour or two). Optimization can come a little later.
But I'll definitely be looking into this ObservableCollection class. That in fact is what one of the 3rd party tutorials recommended developers use, but then when I got involved with their tech support, she was using a regular old List, so that's what I reverted to. It's got me involved in developing gobs of code, but my preliminary results are that it works, so I'd like to carry it through to completion before I change directions and do it "the right way."
|
|
|
|
|
In addition to my other reply...
The magic DataContext:
Any time you have a binding that doesn't explicitly set a source (be it a direct
source, RelativeSource, etc), then an attempt is made to bind to the object set
on the DataContext property of the target element.
If there's a DataContext set and the Path of the binding is not found on that object,
then the binding silently fails (almost silently - you'll get a handy warning in the
debugger output window).
If no DataContext is set on the element, then the system walks up the tree and tries the next
(parent) element's DataContext. This is repeated to the root element. If a source
still wasn't found after all that, the binding will fail and you'll get the message in the
debugger output window.
This allows you to set the DataContext at an appropriate place in the tree so it is
accessible by more than a single element if necessary - very flexible.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm not sure this post is relevant to what I'm doing since I'm using neither Linq nor SQL. Is this thinking on my part correct?
|
|
|
|
|
You looked at the wrong DataContext. The DataContext we're referring to
is a property of every UIElement.
I think it's very relevant - you'll probably want to set the DataContext to
your list object instances somewhere in your visual tree so you don't have to
use a "global" Application object as your binding source (which is just silly
except for data that needs to be at application scope
From what I gathered, you want data at the scope of each Window (different set of data
for each window, so set the DataContext to that data on the Window or any appropriate
child element of the window).
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: You looked at the wrong DataContext.
I do stuff like that all the time. I bring up a class in MSDN and start reading and think, what is this nonsense? Then I look where the article stems from and its Visual Basic or something!
|
|
|
|
|
I've got it all working now, exactly the way I want it. But things got solved in unexpected ways. I couldn't support updating the ListView in XAML if I wanted to replace the values in it multiple times in the same instance of the containing window. I had to initially set ItemsSource to null and Clear() the ListView, and only after setting all the values in the ItemsSource could I bind the data to the control through a simple assignment statement in code-behind.
This solved all my problems! so Mark Salsbery was on the right track when he advised me not to use XAML for the data binding. Maybe there's a way of assigning it in XAML but in this case, I don't know what it is. And where XAML is supposed to be so much more concise than code behind, in this case it is horrendously more complicated! I don't have to worry about "RelativeSource", "AncestorType", "Path", or any of that other BS in XAML. I just prepare my data source and do a one line assignment when it's done, like this:
metadataGrid.ItemsSource = PhotoMetadataList;
Voila! Mission accomplished! What could be simpler? PhotoMetaDataList is local to the window instance and I don't have to worry about binding to something in Application.Current, which was about as ugly as you can get. Each window instance has its own data source and everything works perfectly!
My apologies for not following up on all the posters who gave me fine suggestions, but as the saying goes, if it ain't broken, don't fix it! Thre's valuable suggestions in this thread that will come in handy in the future. And BTW, my problems had absolutely nothing to do with the 3rd party control I'm using, which is just about the spiffiest control in the universe. All my problems were with understanding the basics of pure WPF data binding. No wonder the 3rd party tech support was impatient with me.
Look up Matthew MacDonald's suggestion on page 608 for a replacement to the Windows Forms' DataGridView to find out what control I'm actually using. Unfortunately the book is out of date in suggesting that you can get the standard edition for free. However, it was correct information when I bought the book and I jumped at the chance to get it free! It will currently set you back $300, and thousands if you want the Professional edition. They must have had an army putting this thing together.
modified on Thursday, June 25, 2009 6:28 PM
|
|
|
|
|
Howdy Fellow's:
I've been searching information about WPF's transitions on the web.
I'm trying to develop a "slide" transition to make my appllication look smother, but I keep encoutering issue with all the examples I've found on the net.
in the transition, the image flicks in the borders. I don't want this to happen, but all the examples seem to have to same problem.
I also tried to run my applicattion on a faster and newer machine, but the result was the same. Could it be that windows XP handles the bitmap effects and transitions with software instead of using the hardware?
Thanks for the help.
Cheers
|
|
|
|
|
fgimenez wrote: Could it be that windows XP handles the bitmap effects and transitions with software instead of using the hardware?
No. Windows XP handles all our transitions just fine. Do you have a good video card ? Are your drivers up to date ? What are you doing exactly ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Yes, I've tested in several machines( with different and better video cards) and the result was always the same, the animation flicks.
I'm new to all the wpf developing so I'm building a very simple animation. There is a rectangule with a gradient on the screen and I move it from left to right. That's all.
The size of the rectangule remains the same, only it's position changes.
I'm using the Expression Blend to create the animation and the see the XAML code. The animation looks generated is this one:
<Storyboard x:Key="TextAnimation">
<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)">
<SplineColorKeyFrame KeyTime="00:00:02" Value="#FFFF0000"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="testAnimation">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" KeySpline="0,0,1,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="340" KeySpline="0,0,1,1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" KeySpline="0,0,1,1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="225" KeySpline="0,0,1,1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
As you can see, the propertys being changed are the X and Y positions.
The problem is that as the rectangule moves throught the screen, the borders flick( you can see how they are been drawn very quickly) and this gives a very shaby effect.
Is there any other way to do this? All the examples and libreries I've found have the same problem.
Again, thanks!
Cheers
|
|
|
|
|
I am beginner, trying to understand Silverlight2Chat application. I followed instructions on Build a Silverlight 2 Web Chat Application[^]to create Silverlight2Chat project in visual studio. My solution explorer show the project exactly as in the picture on the above link.
In the web.config file I changed the connection string as follows:
<add name="LinqChatConnectionString" connectionString="Data Source=[STUDYMG];Initial Catalog=LinqChat;Integrated Security=True;" providerName="System.Data.SqlClient"/>
I created two records in dboUsers, and one record in dbo.Room tables.
Now to see how it works, I right click on Silverlight2Chat in the solution explorer in Visual Studio, then choose 'View in Browser', It shows me the login page, I enter credentials and then click on login button, but nothing happens.
I also did 'View in Browser' for Silverlight2ChatTestPage.html, which also shows me the login page, but nothing happens when I enter credentials, and click on login button.
What am I missing?
|
|
|
|
|
You need to actually run the app instead of just viewing it in a browser.
Try choosing Debug/Start new instance or hit the F5 key.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did try running the app with F5 key and ctrl+F5. but still nothing happens when I click Login button after entering credentials.
|
|
|
|
|
I browsed quickly over that article....is there a WCF service involved?
If so, do you have that running as well?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
ValidateUser method uses WCF service to validate the user name and password entered by the user. I am currently running this app from within Visual studio. How do I run the WCF service?
I appreciate for your help.
Thanks.
|
|
|
|
|
I haven't seen how the projects are configured, but it is possible to
run both the server and client sides at the same time in the debugger.
Right click the server project, choose Debug/Start instance. Then do the same
for the client project.
Beyond that I can only guess without downloading the code...I'll see if I can do that...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Debug/Start instance starts the app as described in my previous msg, but does not work.
I opened server explorer in visual studio 2008, and expanded 'services' tab. It does not show WCF service running. How do I make this service run?
Thank You.
|
|
|
|
|
deep76 wrote: Debug/Start instance starts the app as described in my previous msg, but does not work.
You have TWO APPS to start.
msalsbery wrote: Right click the server project, choose Debug/Start instance. Then do the same
for the client project.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok. I started both apps in debugger and logged in. Now it is working, and shows the msgs that two users sent through chat. But, it does not show the text box where msg is being typed, looks like the screen is incomplete. I checked the code on Chatroom.xaml. It does have a textbox named TxtMessage, which looks like the place where user types in a msg.
<TextBox x:Name="TxtMessage" TextWrapping="Wrap" KeyDown="TxtMessage_KeyDown"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Width="360"
BorderThickness="2" Margin="0,0,10,0"/>
But, this text box is not seen when I start the app and login. I logged in as two different users from two different browser windows. Both could pass msgs, but could not see the text box where msg was being typed.
Thank you. Greatly appreciate your help.
|
|
|
|
|
TxtMessage is the TextBox where messages are typed.
How were you able to pass messages without seeing the textbox?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did not see the textbox, but just typed something and pressed 'enter'. It appeared in the msg box above.
|
|
|
|
|
Interesting.....I can see it fine.
I have no clue what's up on your end
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What browser are you using. I tried on IE8.0 where it shows msg box, loggedin people, but no textbox where msg is typed.
But, if I launch it using Firefox3.0.11, the page is completely blank.
|
|
|
|
|
deep76 wrote: What browser are you using
Firefox 3.0.11
I see a blank page when I launch the web app, which as far as I can tell
from a quick look at Chatroom.aspx (the default page), shouldn't be blank.
So instead of debugging that, I just (on the blank page) change "Chatroom.aspx"
to "Silverlight2ChatTestPage.html" and that one shows the silverlight app.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
deep76 wrote: if I launch it using Firefox3.0.11, the page is completely blank
In Chatroom.aspx, change the body to this
<body style="height:100%;margin:0;">
<form id="form2" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/Silverlight2Chat.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
</div>
</form>
</body>
and it shows up like it should.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank you. It works now.
|
|
|
|