|
I know this is no consolation to you, but I use Blend precisely to get round issues like this.
"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
|
|
|
|
|
Blend. BAH! Blend is for people that are tired of complaining about the IDE and the general suckiness of WPF.
I will not rest!
I will not give in!
I will not...
Oh look! Something shiny!
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Shiny's good. I like shiny.
"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
|
|
|
|
|
Do you have forward resource references? Seems to me that's what that bug is related to.
Forward resource references were already known as a bad idea...
I also saw you used a "StaticResource" in there....depending on where that desired
resource is in your chain of dictionaries, you may need to use DynamicResource.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I also saw you used a "StaticResource" in there....depending on where that desired
resource is in your chain of dictionaries, you may need to use DynamicResource.
I changed it from StaticResource because the IDE complained about me trying to use WPF for production code...
Okay, that was sarcastic - at least the last part was...
I've given up for the day (I feel so... French), and I'm just gonna sit here and stare at my monitor - in some ways, I will remain as productive as I've been all day...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I added this to Buttons.xaml, and the problem is resolved:
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
I thought that if the dictionaries were all merged, their content would be magically "found". I guess I'm expecting too much.
CRAP
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Tuesday, May 12, 2009 3:18 PM
|
|
|
|
|
Hi,
I have created a WPF application(browser) having a XamDatagrid. I populated the grid with db values. When i placed the gadget in Windows Sidebar i am unable to see the binded data. And also close, maximize and drag buttons of the sidebar get disappears. Any solution for this will be appreciated. .Thanks in advance
Gomathi R
|
|
|
|
|
Is this a WPF issue or a sidebar gadget implementation issue?
I'm wondering if you'll get more help on a more appropriate message board...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
MemoryStream stream = new MemoryStream(b); //b is byte[]
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = stream;
image.EndInit();
when i use this code i receve an error
Exception message is {"No imaging component suitable to complete this operation was found."}
inner Exception is {"Exception from HRESULT: 0x88982F50"}
what is th problem
|
|
|
|
|
the BitmapImage needs to get some members filled.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I am also interested in which members this might be. Which are the most important ones?
Thanks,
Lars
#pragma error( disable : * )
|
|
|
|
|
Whenever I've seen this error, it's been caused by one of two things:
1. The image data needs to be offset. In the Northwind data, you have to offset the image byte array by 78 bytes (I think - you'd need to look this up, but this rings a bell)
or
2. You aren't actually located at the right place to read the data from in your stream, i.e. you've gone past the end of the data. Use stream.Seek(0, SeekOrigin.Begin); to reset the stream to the start of the byte array.
Note that option 2 is just a variation on option 1.
"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
|
|
|
|
|
Hi,
I think, in my case its different
I am receiving an image from a webcam. What I want to do is, The image data is provided through an Image which uses a FormatConvertedBitmap as ImageSource. This bitmap uses a TransformedBitmap as BitmapSource (this all looks a bit like a decorator pattern).
Now I do the following: I call CopyPixels on the TransformedBitmap with an pre allocated buffer with size: source.PixelWidth * source.PixelHeight * source.Format.BitsPerPixel / 8. The stride is source.PixelWidth * bytesPerPixel and the offset is 0.
I pass this buffer as an argument to a memory stream and try to use this stream as StreamSource for a BitmapImage.
It produces exactly the error message mentioned above ;(
I played with CachingOptions (set it to None), CreationOptions (PreservePixelFormat) -> nothing ;-(
Any Ideas?
Greetz,
Lars
#pragma error( disable : * )
|
|
|
|
|
If you get this message, it generally suggests that the system cannot find a CODEC that could be used as a suitable source. Try saving the data out to disk and seeing if you can load it with a standard imaging application.
"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
|
|
|
|
|
i have exactly the same problem and i am not surprised because there is no way this could possibly work. nowhere do you actually set the image width or height or the pixel format of the byte array (in my case it's just a string or RGB values) - nor can i find a way you might actually set these - but they would definitely be required in order to initialise a BitmapImage.
if you read from a file or an in memory image format this information is contained in the header of a specific image format such as png or jpg - but in the case of simple raw image data it is not. hence the exception. there obviously must be another solution. sadly i have searched high and low and still have no answers!
|
|
|
|
|
We have an application developed in C# with WPF (.NET Framework 3.0)
The main window has a glass border, and a child window containing a WebBrowser is centered within it:
<br />
WPF main window <br />
-> Child window - frame control <br />
-> Page <br />
-> WindowsFormsHost<br />
-> WebBrowser<br />
Because we used .NET 3.0, we have to put WebBrowser in WindowsFormsHost, and it can't show if we set the window property AllowTransparency to true.
Now, on Windows XP, when the user clicks the Shutdown button on the Start menu, a dialog is displayed with various choices (shutdown, restart, etc.) while behind it the entire desktop appears to fade from color to shades of gray. When this occurs, our main window becomes hidden, while the page window is still displayed on the screen.
We have already set page window's owner to be the main window, but this did not help. Therefore, I have come to the conclusion that I must intercept the "fade to gray" event and... do something to mitigate this ugliness. So: does anyone know how I might allow my program to be notified prior to the fade to gray?
Glad to discuss with you and best wishes.
|
|
|
|
|
Add the following WndProc in:
private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
const WM_QUERYENDSESSION = 0x0011;
switch (msg)
{
case WM_QUERYENDSESSION:
break;
}
return IntPtr.Zero;
} Alternatively, you could have a thread monitoring System.Environment.HasShutdownStarted;
The advantage of the WndProc approach is that it gets called when the event is fired, and doesn't require a separate thread.
Now, to add the WndProc, you do the following in the Window loaded event:
void MyWindow_Loaded(object sender, RoutedEventArgs e)
{
HwndSource src = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
src.AddHook(new HwndSourceHook(WndProc));
}
"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
|
|
|
|
|
Thanks for your reply,
i tried it, it doesn't work.
the WPF window can't catch WM_QUERYENDSESSION message...
Glad to discuss with you and best wishes.
|
|
|
|
|
My WPF application used high CPU usage after about 30 minutes, then i break the application to find out what code spent high CPU usage, but i got nothing.
Visual Studio 2008 can't display current running code, but i found this in "Call Stack" panel:
<br />
[In a sleep, wait, or join] <br />
mscorlib.dll!System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) + 0x8f bytes <br />
System.dll!System.Net.TimerThread.ThreadProc() + 0x2f9 bytes <br />
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x66 bytes <br />
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x6f bytes <br />
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes <br />
what's this? what's matter with high CPU usage? and how to reduce the CPU usage?
PS:
I used Performance Profiling for WPF tool to found out which events or element take high CPU usage, then we found: Tick(TimeManager.Tick()) was take about 40% CPU usage of app. which events will call TimeManager.Tick? how to reduce it? – Cooper.Wu 5 secs ago
Glad to discuss with you and best wishes.
|
|
|
|
|
TimeManager is part of the framework and it is related to the animation subsystem. Do you have a lot of animations going on in your app?
|
|
|
|
|
We have two textBlock like this: (we used .NET FW 3.0)
<br />
<TextBlock Grid.Column="0" Name="tabName" Style="{StaticResource textBlockBarStyle}" HorizontalAlignment="Left"><br />
<TextBlock.Margin><br />
<Binding Converter="{StaticResource dpiConverter}"><br />
<Binding.ConverterParameter><br />
<Thickness Left="3" Top="6" Right="0" Bottom="0"/><br />
</Binding.ConverterParameter><br />
</Binding><br />
</TextBlock.Margin><br />
</TextBlock><br />
and
<br />
<TextBox x:Name="txtBoxHelp" <br />
IsReadOnly="True" Style="{DynamicResource txtBoxHelpStyle}" <br />
IsTabStop="False" <br />
Text="some text" MouseLeftButtonDown="txtBoxHelp_MouseLeftButtonDown"><br />
<TextBox.Margin><br />
<Binding Converter="{StaticResource dpiConverter}"><br />
<Binding.ConverterParameter><br />
<Thickness Left="7" Top="0" Right="0" Bottom="0"/><br />
</Binding.ConverterParameter><br />
</Binding><br />
</TextBox.Margin><br />
</TextBox><br />
these two textBlock work well on others OS, but sometimes miss on the Windows XP Home Version with SP3. we have tried many ways to refresh these, but failed.
we tried: 1, UpdateLayout 2, InvalidateVisual 3, changed the set Text property in code to binding mode.
how to force these controls to refresh?
Glad to discuss with you and best wishes.
|
|
|
|
|
It is possible in WPF do an immediate, forced refresh of a control, but it's not as simple as Winform's .Update or .Refresh methods - because the redrawing of the VisualTree doesn't happen while you're GUI thread is busy handling a message from the Dispatcher (which, in your user code, you almost always are).
The work around is to temporarily create a Dispatcher "frame", which allows a refresh of the VisualTree to be performed immediately. Apparently this is a bad idea, but it does work. Consider the following helper class:
public class WpfApplication : Application
{
private static DispatcherOperationCallback exitFrameCallback = new
DispatcherOperationCallback(ExitFrame);
public static void DoEvents()
{
DispatcherFrame nestedFrame = new DispatcherFrame();
DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame);
Dispatcher.PushFrame(nestedFrame);
if (exitOperation.Status != DispatcherOperationStatus.Completed)
{
exitOperation.Abort();
}
}
private static Object ExitFrame(Object state)
{
DispatcherFrame frame = state as DispatcherFrame;
frame.Continue = false;
return null;
}
}
See also: http://blogs.msdn.com/jfoscoding/archive/2005/08/06/448560.aspx
Vote me please
Niladri Biswas
|
|
|
|
|
Tried this approach when doing TabControl.Items.MoveCurrentTo... and it has no effect. The tab control is still not redrawn. Any ideas? Thanks.
|
|
|
|
|
In MSDN there is a demo about styling scrollviewer.
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid >
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18"/>
<RowDefinition Height="0.00001*"/>
<RowDefinition MaxHeight="18"/>
</Grid.RowDefinitions>
<Border
Grid.RowSpan="3"
CornerRadius="2"
Background="#F0F0F0" />
<RepeatButton
Grid.Row="0"
Style="{StaticResource ScrollBarLineButton}"
Height="18"
Command="ScrollBar.LineUpCommand"
Content="M 0 4 L 8 4 L 4 0 Z" />
<Track
Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="true">
<Track.DecreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageUpCommand" />
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb
Style="{StaticResource ScrollBarThumb}"
Margin="1,0,1,0"
Background="{StaticResource HorizontalNormalBrush}"
BorderBrush="{StaticResource HorizontalNormalBorderBrush}" />
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton
Style="{StaticResource ScrollBarPageButton}"
Command="ScrollBar.PageDownCommand" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton
Grid.Row="3"
Style="{StaticResource ScrollBarLineButton}"
Height="18"
Command="ScrollBar.LineDownCommand"
Content="M 0 0 L 4 4 L 8 0 Z"/>
</Grid>
</ControlTemplate>
The code set the second row to 0.000001* and the other tow rows as 18px. Why could not I set the second row to *?
|
|
|
|
|
mildred-frontfree wrote: Why could not I set the second row to *?
You probably could....have you tried it?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|