|
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
|
|
|
|
|
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.
|
|
|
|
|
This[^] blog post will show you how to implement a version of DoEvents(), that should help.
|
|
|
|
|
The normal way to do this in a WPF application is to implement a background worker, where you'd save the items in your background thread, and you'd dispatch the updated progress values back to the calling thread which would update the progress bar.
"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
|
|
|
|
|
Hello
I have a textBox which I want to add some "ghost" text on, which is visible whenever the textbox does not have focus.
I could do it with codebehind, but since I am new to WPF and XAML I would like to do it all from XAML code, to get some practice.
Currently my XAML code looks like this:
<TextBox x:Name="textBoxUsername" Margin="5,5">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsFocused" Value="false">
<Setter Property="Text" Value="Username"/>
<Setter Property="Foreground" Value="LightGray"/>
<Setter Property="FontStyle" Value="Italic"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
What I would like to do, is add another statement to the trigger so
it checks if the text is set by the user.
This is where I need help, I cannot figure out what to write, so
it checks if the text is set by the user or not.
If this is not the right way to solve this, I would be happy to get
an Article/blog/something which describes how to do it
//QzRz
|
|
|
|
|
|
Hello, I have a WPF application which runs in a Window. I would like to change that and have it replace the Windows desktop (this makes sense since the application is a file manager, among other things.).
I need some generic explanation of how to do that because I have no clue if it's possible and how. So far I only understand that I'll probably have to call some Win32 functions. I am imagining something like "take the hwnd H of your wpf window, call GetDesktopWindow() as W, take the parent P of W, and replace H as the child of P". (This is what I seem to understand that I probably have to do, but I may be completely wrong. For example, I may need to implement some COM interfaces or create shell extensions.).
Currently I am browsing the source code of some "shell replacements" like geoshell, but I still can't locate the piece of code which replaces the desktop, and I am not sure this would apply to a WPF application anyway. So, I would be very grateful if somebody pointed at the right direction. Thank you very much for any pointers.
Update :
it looks like I did it with the help of this link[^]. It seems to work. Here is the code (the language is F#):
let tWnd =
let help = Interop.WindowInteropHelper mainWindow
help.Handle
mainWindow.ResizeMode <- ResizeMode.NoResize
mainWindow.WindowStyle <- WindowStyle.None
let mutable pWnd = FindWindow("Progman", null)
pWnd <- FindWindowEx(pWnd, IntPtr.Zero, "SHELLDLL_DefVIew", null)
pWnd <- FindWindowEx(pWnd, IntPtr.Zero, "SysListView32", null)
SetParent(tWnd, pWnd) |> ignore
mainWindow.WindowState <- WindowState.Maximized
modified on Saturday, October 10, 2009 7:47 AM
|
|
|
|
|
Hey All,
I am building a Textbox that will have multiple regular expressions that validate when the control looses focus.
I can get this all to work, but at design time in Expression Blend 3 when I go to set the "Validators" I get and error saying "No types are available for you to add to this collection."
does anyone have any ideas on how I can make this work?
If at first you don't succeed ... post it on The Code Project and Pray.
|
|
|
|
|
Hi,
i have RibbonControl.dll, used in my application. but i want to change the base color of this ribbon control. look at this demo project which i have downloaded from codeproject.com itself.
http://www.codeproject.com/KB/WPF/ribboncontrol/ribboncontrol_demo.zip
can any body help me out..
Thanks!
|
|
|
|
|
I want to receive control when the user clicks a Figure which contains an Image inside of a FlowDocumentReader. I thought PreviewMouseLeftButtonUp would be the event to look for, but it doesn't get control when I click on the image. So I tried the MouseLeftButtonUp event, and I don't get control there either. What do I need to do? Here is my XAML:
<Paragraph>
<Figure
Width=".5 content"
Height=".5 content"
>
<BlockUIContainer>
<Image
Name="placeholderSS"
Source="Resource/RemoveUnwantedImagesPage.jpg"
PreviewMouseLeftButtonUp="placeholderSS_PreviewMouseLeftButtonUp"
MouseLeftButtonUp="placeholderSS_PreviewMouseLeftButtonUp"
/>
</BlockUIContainer>
</Figure>
When ...
</Paragraph>
Addendum: I also tried the same events from the Figure and the Paragraph. No dice. I get no MouseLeftButtonUp event from any of the three places.
The following link asks the same question but none of the replies offered a correct answer. One answer just regurgitated my attempt, claiming it works and it doesn't. I wonder why it doesn't seem to be possible?
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/8e17d9e5-9fb3-4a86-b685-497de3c60e11/[^]
modified on Friday, October 9, 2009 4:13 PM
|
|
|
|
|
All you need to do is handle the PreviewMouseLeftButtonDown event on the Image and set e.Handled = true; . Then you can handle the MouseLeftButtonUp event the way you want. By handling the event (e.Handled), you ensure that the containing item doesn't capture your events.
"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
|
|
|
|
|
Pete O'Hanlon wrote: All you need to do is handle the PreviewMouseLeftButtonDown event on the Image and set e.Handled = true;. Then you can handle the MouseLeftButtonUp event the way you want. By handling the event (e.Handled), you ensure that the containing item doesn't capture your events.
I don't see why you have to do that. You don't have to do it for the TextBox, which also allows highlighting and dragging the highlighted text. See my reply to your earlier post today for a fuller explanation:
http://www.codeproject.com/Messages/3230555/Re-Why-doesnt-Microsoft-support-the-documented-mou.aspx[^]
|
|
|
|
|
Can we use control properties in windows forms from a user control create in Wpf .and currently we are using user control in windows forms....
|
|
|
|
|
Your title was too long here. There was no need to post the whole question in the title, and the answer is yes - if you're using standard properties.
"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
|
|
|
|
|
sorry first for long title..
I mean to say that if i have 3 controls in user control. den can i access events of that controls in my windows forms
|
|
|
|
|
My app is apparently throwing an exception as a result of databinding. Afterward, changes to the controls don't propagate back to the object model (it's like the run time just throws its hands up and says "to heck with it"). Whatever is happening isn't showing up anywhere. No exception, no stack trace, no debugger output, and it isn't making it to the global exception handler either.
I never thought I'd look back wistfully towards developing client side stuff in javascript, but at least there I could get some idea of what was going on. Is there something special I have to do to get this thing to tell me what is going on? I'm using firefox (I wish I could switch for this project, but I don't want to change my default browser for everything else).
|
|
|
|
|
|
So I got my SSL enabled service and non SSL service (both WCF) running fine on my host.
My site is entirely silverlight and is http://****.com
I can call both services fine and results are correct, but however the secured padlock logo will not show up on browser when I am calling the SSL service.
If the access the site and add the 's' at : https://****.com
The padlock will then show up.
But I do not want the site to be SSL enabled for the entire time. I want it only to be SSL enabled only when customer checks out or login.
Keeping in mind my entire site is one big silverlight app, how do I switch to https or enable the padlock logo only when I need it to?
|
|
|
|
|
Are you sure that need the padlock to show up?
From what you have said, you have secured the call to the service (assuming your endpoints etc. are looking at the https services): e.g.
<endpoint address="https://nigel.company.co.nz/MyService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
- but that is all in the background.
Even though you didn't access/download the Silverlight xap with https it will still be communicating directly with the services over https if they are configured that way.
|
|
|
|
|
Thank you Nigel, and yes the SSL service endpoint is correct and everything is working fine.
I know I am calling the service with SSL enabled and fiddler can see it is SSL, but it is all in the background.
I need to show the padlock because customers (and my client) will only believe they are SSL secured only if the browser tells them.
I could says with a textblock that the login is SSL secured, but the browser isnt showing the padlock and it is dubious to them.
|
|
|
|
|
I know what you mean. I have just been talking to my colleague about the same thing.
The funny thing is that once the xap has been downloaded (via https for example) and is running, whatever the browser says is irrelevant, you can still go ahead and be as un-secure as you like in the background with your service calls (assuming you have the clientaccesspolicy.xml in place).
That's my understanding anyway - I would like to be proved wrong though.
Cheers.
|
|
|
|
|
While trying to find a solution to this problem, I read from somewhere that SSL to non-secured service calls would be denied. I could not be sure, but if it is not the case, you might have something there Nigel.
Going back to topic, I would appreciate any suggestions and help on this matter. Is there anyway to switch from HTTP to HTTPS while not losing silverlight page contents?
|
|
|
|
|
Soulforged wrote: SSL to non-secured service calls would be denied
That's the basis of the problem. By having the clientaccesspolicy.xml with https and http included you are allowing calls from a Silverlight app in http to services in https and vice versa. It is my understanding that the browser is ignorant of what Silverlight is doing in the background so the padlock can be misleading. You could run the app in https with a nice padlock and then call services over http and the padlock will stay there. Unless you remove/alter the clientaccesspolicy.xml and stick to either all http or all https.
I'll let you know if I find out any more info.
Cheers
|
|
|
|
|
Hi,
I am working on a WPF application,
one of my wpf windows has Listbox -> stackpanel -> Image and text block.
Let me put my xaml for better understanding
------------------------
<ListBox Name="listboxImage" HorizontalContentAlignment="Center" DataContext="Binding Element=listBinding,Path=SelectedItem" SelectionChanged="listboxImage_SelectionChanged"><!-- --><br />
<ListBox.ItemTemplate><br />
<DataTemplate x:Name="dtTemplate"><br />
<StackPanel Orientation="Vertical" Name="stackpnl"><br />
<Image Name="imagelisted" Source="C:\Casket.png"/> <br />
<TextBlock Name="textblockProductID" Text="{Binding Path=ProductID}"/><br />
</StackPanel><br />
</DataTemplate><br />
</ListBox.ItemTemplate><br />
</ListBox>
----------------------
Here is what I am trying to do behind the scene
-----------------
Binding listBinding = new Binding();<br />
listBinding.Source = ds.Tables[0];<br />
listboxImage.SetBinding(ListBox.ItemsSourceProperty, listBinding);<br />
listboxImage.SelectedIndex = 0;<br />
<br />
byte[] bytes = (byte[])ds.Tables[0].Rows[0][1];<br />
<br />
MemoryStream stream = new MemoryStream();<br />
stream.Write(bytes, 20, bytes.Length - 20);<br />
<br />
<br />
PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);<br />
ImageSource source = decoder.Frames[0];<br />
<br />
this.imageTest.Source = source;
-----------------
Please, note that imageTest is the TestImage I have put outside the listbox, which works fine.
Now, Of course I am not setting Image's Source property "???????" but, in place of that
I want to set that property dynemically form code, as I am twicking the byte[] field.
So again, my question is how can I set source property to something from the code?
I have object of ImageSource ready,
So all I have to do is my "(from ListBox)ImageName.Srouce = myobject Of ImageSource Type.
I am new to WPF and DataBinding with it.
|
|
|
|
|
You could try making an IValueConverter that turns a byte[] into an ImageSource. Then you could say
<!-- put this in the resources section of the window
or usercontrol
(assuming you make a class called
ByteArrayToImageSourceConverter and the namespace
it is in is mapped to local in XAML) -->
<local:ByteArrayToImageSourceConverter
x:Key="B2IConv" />
<!-- put this in the list box item template -->
<Image Source="{Binding ByteArrayProperty Converter={StaticResource B2IConv}} />
It looks like you already have the code for converting a byte array to an image source, so all you have to do is look up the methods for IValueConverter and you should be set. Don't feel like you have to actually ConvertBack from the converter.
|
|
|
|