 |
|
 |
Correct me if I'm wrong, but you want the rectangle to move the same way whether there's rotation applied or not, right?
If so, then the center of rotation should stay at 50,50:
<Rectangle.RenderTransform> <TransformGroup > <RotateTransform Angle="{Binding ElementName=AngleTextBox, Path=Text}" x:Name="rotate" CenterX="50" CenterY="50"/>
<TranslateTransform X="{Binding ElementName=XSlider, Path=Value}" Y="{Binding ElementName=YSlider, Path=Value}"/> </TransformGroup> </Rectangle.RenderTransform>
Mark Salsbery Microsoft MVP - Visual C++
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Did you try putting the TranslateTransform before the RotateTransform? Transforms are not commutative (A*B <> B*A), which stems from their underlying representations as matrix multiplications, which are also not commutative.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Morning folks,
I need to generate a grid programatically an image per cell in a grid-like fashion that could be 100 x 100 or more, so I need a high performance control that will be able to handle interacting with the grid once its loaded. I've tried a stack panel method which did work quite well but there seemed to be a bit of a performance lag on it. I'm a bit new to WPF so if you have any suggestions as to what would be best to use that's be fab 
Thanks very much, Becky
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hopefully I do not need a lot of re-do here (and can do it).
I have a model that does some searching on various PC's hard drives for some files. Depending on those files variuos data is loaded into a container.
In the model I have spun up some BG workers to do the searching depending on how many PCs there are (PCs are determined by the model at run time). I would however like to have my progress posted out of my library into the applications using the model (i.e. some WPF apps). How can I do this and have them updating properly?
I know that WPF expects DP's but the model is incapable of bubbling things in that matter (so it seems). My Model is just a custom object (inherits from a custom Interface). What am I misssing? Seems like having your model use BGWs is critical and having them post their progress is a requirement from end users (to avoid what the *# is the program doing??? People want to know when it is done...)
Your help is appreciated.
"9 Pregnent woman can not have a baby in 1 month" -Uknown
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
You don't need a DP here. This[^] article gives you some useful insights into using a BackgroundWorker with WPF, and can be easily adapted into MVVM.
"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
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Thank you! That is what I was needing.
"9 Pregnent woman can not have a baby in 1 month" -Uknown
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
hi friends i have multiple expander control in dockpanel with Dock property set to be top. no i want to create expander in such a manner that it slideout from dockpanel when i click the slide out button so that my expander expand to right side outside the dockpanel such like popupControl.
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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm trying to use Log4net to log messages within my application. I'm adding a WPF window and want to stream the messages to the window. Log4net provides a TextWriterAppender that takes a StringWriter and writes logged events to the StringWriter, flushing it after each event.
I want to simply connect the output of the StringWriter as the Text property on a TextBox. When I started this, it seemed simple and obvious - now I'm less sure. Ideally, I would simply like to bind the StringWriter to the TextBox, but haven't found the incantation.
The basic problem is that the StringWriter doesn't provide something like the INotifyPropertyChanged event to trigger code output a new log message (unless there is something behind the scenes I haven't found).
I've see many examples of binding, all of which seem to presume that I have control over the writer itself. Am I missing something simple (I hope), or is this really not that straightforward.
Any thoughts/help appreciated.
Thanks,
--Don
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Don - based on your post here, I knocked a sample application up using a custom appender. You can find it here[^].
"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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I am using Infragistics XamOutlookBar bar, my form's layout is rounded from the left and right, on the left I placed that Outlook bar control and on the right I placed Infragistics XamDockManager control. I load the forms on the right area through XamOutlookBar, since my form is in rounded shape from left and right, so please advice me how I give curve on the right for a particular control.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
ahsansharjeel wrote: How do I make rounded corners for textbox, combobox and other controls
They have borders, which can have a CornerRadius applied to them.
"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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Until recently, this forum was not overrun with idiocy. I guess WPF is mainstream now.
What have you tried ? What research have you done ? What are you hoping for here, that someone will give you source code ? Your question suggests you've done nothing bar ask us to do it for you.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If you don't know the answer, then do not reply. its the best way, I just started WPF few days back, I have lot of questions. I have live projects which have to be written in WPF, I will ask forums, no one reply me like this. I help lot of peoples around me for .NET 2.0, SQL Server, Designing and other things, I never discourage any one. If you don't know, just stop replying, no one like this type of answers.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Christian has asked a fair question. What have you done so far? Before you get all shirty, you might want to consider that he has actually asked you what the starting point is? If you are just after the final couple of bits of information for an almost complete implementation, then you aren't going to want us to tell you about how to bind data into the combo box - that's a waste of your time and ours.
More importantly though, there is an expectation that you have done some work for yourself so far. Code Project is predicated on the fact that you have a starting point. Nobody here has the time or inclination to tell you how to write a fairly complex control from scratch. That's what the articles are for.
"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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I have a list: List<Image> ImgRow1 = new List<Image>(); and i set: foreach (Image item in ImgRow1) { item.MouseDown += new MouseButtonEventHandler(item_MouseDown); } in private void item_MouseDown(object sender, MouseButtonEventArgs e) { } and i want to get index of sender (for example: ImgRow1[2] => index=2 ). Sorry for my english. Thank !
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If ImgRow1 is a property like:
public List<Image> ImgRow1 { get; set; } and is in scope in the event handler, then you can modify the event handler like this:
private void item_MouseDown(object sender, MouseButtonEventArgs e) { Image myImage = (Image)sender; int index = ImgRow1.IndexOf(myImage);
MessageBox.Show(index.ToString()); }
Or,
You could create your own "IndexedImage" class with a ListIndex property, inheriting from Image and use that.
public class IndexedImage : Image { public int ListIndex { get; set; }
public IndexedImage() { } } When you add the event handler, add the list index as well:
foreach (IndexedImage item in ImgRow1) { item.MouseDown +=new MouseButtonEventHandler(item_MouseDown); item.ListIndex = ImgRow1.IndexOf(item); } Then in the event handler you can get the ListIndex property:
private void item_MouseDown(object sender, MouseButtonEventArgs e) { IndexedImage myImage = (IndexedImage)sender; MessageBox.Show(myImage.ListIndex.ToString()); }
but that has other issues, in that the index may change later on, so the class would need to be more complicated in reality.
modified on Sunday, October 11, 2009 4:51 PM
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
This is a follow-up to an post I made a few days ago that didn't receive any answers. I was asking why events like MouseDown and MouseUp cannot be captured inside FlowDocument containers. Those mouse events don't seem to be generated, and I can't find any explanations either in MSDN or the Microsoft WPF forums explaining why mouse events are thrown away. You'd think they'd explicitly state why this happens. The problem isn't mentioned in any of the several WPF books I also have. When other people ask the same question on other forums, no one really comes up with an answer, not that I've found anyway.
There is one mouse event that is reported, and that is the Click event for UI objects that can listen for that event, such as the Button and Hyperlink elements. These need to be placed inside BlockUIContainers or InlineUIContainers within FlowDocuments. What I was actually trying to do was receive control on a MouseUp event when the user clicked a thumbnail of a screenshot (in the form of an Image element) within a FlowDocument, so that I could bring up another dialog showing the screenshot full size. So one way to get this effect is to put the thumbnail of the screenshot on a button, inviting the user to click the button to get the dialog showing the screenshot full size. That works rather nicely and is a straightforward solution. But an even more attractive option is an inline Hyperlink:
<InlineUIContainer> <TextBlock> <Hyperlink Name="optimal" Click="optimal_Click" > Screenshot </Hyperlink> </TextBlock> </InlineUIContainer>
In any case I think that for some reason, Microsoft is deliberately crippling all elements derived from TextElement (such as Paragraph). All I'm asking for is an explanation for why they do this. Maybe the answer is as simple as, "You should be using Button or Hyperlink within FlowDocuments to do such things." It's actually rather annoying that Microsoft documents all the mouse and preview mouse events for TextElements as if they're all legitimate and yet none of them do anything. Based on the number of Google responses I get when I tried to find out how to get mouse events inside FlowDocuments, the MSDN documentation sure is sending a lot of people on wild goose chases.
modified on Sunday, October 11, 2009 11:26 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
They aren't crippling these events. They are capturing them because they have a particular purpose, i.e. they are captured so that you can do things like drag/highlight text, or select paragraphs.
"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
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I also saw your answer to my previous post. So I guess I should have been looking for PreviewMouseLeftButtonDown instead of PreviewMouseLeftButtonUp. The only reason I was looking for Up instead of Down is because I wanted to make it look like a Click event.
My wording, "crippling these events," was probably too extreme, but not totally off base, it seems to me. Pre-empting would perhaps be a better term. Microsoft isn't literally crippling these mouse events, but it is pre-empting them, for selecting text. But now I don't understand why it has to do this. For example, it doesn't do it for the TextBox element. You can select text in a TextBox and drag it somewhere else, and at the same time, capture PreviewMouseLeftButtonUp. I know because I do that all the time.
Maybe there's a good reason for pre-empting these mouse events for the TextElement class. But what is it? I wasn't able to find any MSDN documentation explaining this, and if it is documented somewhere, it must be pretty obscure because I ran into a lot of posts Googling with the same issues I had, with no one giving your answer.
I think pre-empting is a fair description, because if I do capture the Down event to bring up a dialog, that interfers with highlighting (and perhaps dragging) text, even if I don't say e.handled = true. As mentioned above, this isn't true for the much simpler TextBox element.
In any case, after wrestling with various possibilities, I saw that the best way to accomplish what I want is to put a Hyperlink inline in my text and capture its Click event. That looks very clean for the user and doesn't interfere with text highlighting at all. So in the end I got what I want without intercepting any of the mouse events (other than Click).
modified on Sunday, October 11, 2009 8:15 PM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi
I'm having a bit of an issue with my progress bar in WPF. Let me first explain why I want a progress bar. I have a list of products that I save back to a database when clicking a Save button. Sometimes this list can contain quite a lot of items, and this takes a while to save. I use a for loop to loop through and save each item in this list. So what I want to do is increment the progress bar after each loop iteration. Is this possible? Below is what I tried doing but it only updates the progress bar after the loop has finished, even though I'm running it on a different thread:
for (int i = 0; i < someList.Count; i++) {
new Thread(delegate() { UpdateProgress(100 / productPartsList.Count); }).Start(); } public void UpdateProgress(double increment) { progressIncrement = progressIncrement + increment;
Dispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback)delegate { progressBar1.SetValue(System.Windows.Controls.ProgressBar.ValueProperty, progressIncrement); }, null); }
Any hints?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I think you have to use another DispatcherPriority flag. Because : DispatcherPriority.Background means the enumeration value is 4. Operations are processed after all other non-idle operations are completed. So i would recommend you to use at least DispatcherPriority.Normal or you also could try DispatcherPriority.Render .
Cheers Noodles
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks Noodles. That didn't help though, and I tried every priority available. Here's another code sample I tried: NOTE: This is called inside my loop, so it gets done for every loop iteration
System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart( delegate() { System.Windows.Threading.DispatcherOperation dispatcherOp = prgbSave.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Render, new Action( delegate() { progressIncrement = progressIncrement + (100.0 / productPartsList.Count); prgbSave.Value = progressIncrement; } ));
dispatcherOp.Completed += new EventHandler(dispatcherOp_Completed); } )); thread.Start();
This does the same The progressbar only gets updated after the loop has completed.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |