|
I've been trying that, and I must be missing some fundamental skill. I have this:
In a separate assembly (a sub-project in the solution)
Styles.xaml
<Style x:Key="StyleUDPBaseButton" TargetType="{x:Type Button}" >
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="0.40" />
</Trigger>
</Style.Triggers>
</Style>
Buttons.xaml
<Style x:Key="ToolbarButtonNewServiceOrder" TargetType="{x:Type Button}"
BasedOn="{StaticResource StyleToolbarButtonEx}" >
<Setter Property="ToolTip" Value="Create a new service order" />
<Setter Property="Template" >
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Image Source="/CometResources;component/Images/GlassServiceOrder64.png" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
In the application assembly
Window1.xaml.cs
<Grid Name="gridToolbarObjects" MinHeight="41" MaxHeight="41">
<Button Name="buttonNewServiceOrder" Style="{DynamicResource ToolbarButtonNewServiceOrder}" />
</Grid>
App.XAML
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/CometResources;component/Styles.xaml" />
<ResourceDictionary Source="/CometResources;component/Buttons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
I'm getting the ever-informative exception that states:
startIndex cannot be larger than length of string.<br />
Parameter name: startIndex
This tells me that it can't find one of the things in my string of derived styles. Actually, it doesn't give any indication of what's really wrong - I had to google it, but I digress.
What am I doing wrong, Obi-Wan? You're my only hope.
"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
|
|
|
|
|
Looking at your markup here, it looks like you're using an external resource dictionary. Try using the following instead:
<ResourceDictionary Source="pack://application:,,,/CometResources;component/Styles.xaml"/>
<ResourceDictionary Source="pack://application:,,,/CometResources;component/Buttons.xaml"/>
"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
|
|
|
|
|
No change... :/
"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
|
|
|
|
|
You might find this[^] a useful resource.
"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
|
|
|
|
|
Yeah, I already found that - comment: Big deal MS - the "fix" is coming in VS2010. In the meantime, I'm f*cked because we don't use tools here that are purposely labeled "beta"...
"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 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?
|
|
|
|