|
Its a bug, some workarounds are using WindowsForms Clipboard class or PInvoke.
I encountered this a while back and seem to recall that copying the data to a new bitmap fixed it. I couldn't seem to find all of the posts that were helpful then, when searching google your question was near the top of the results .
I found that the problem was with the alpha values not being set try this method which ignores them.
if (Clipboard.ContainsImage())
{
BitmapSource source = Clipboard.GetImage();
FormatConvertedBitmap fb = new FormatConvertedBitmap(source, PixelFormats.Bgr32, null, 0);
ImagePreview.Source = fb;
}
Another method is at http://shevaspace.spaces.live.com/blog/cns!FD9A0F1F8DD06954!441.entry
|
|
|
|
|
Hi,
Thanks for the reply, it worked. Now I'm having another problem, related to an Image control and it's caching.
I have this image from the clipboard, tha can be very large, and want to show it in a WPF Image control. The Image size is fixed, so the image is thumbnailed as expected, but the Image control keeps the memory for the entire image instead of the thumbnailed one. I read that you must set the property DecodePixelHeight (or width) of the BitmapImage used as the source of the Image control.
The problem is that I'm using the FormatConvertedBitmap as the source, and it doesn't have those properties.
Any clue on how to build a BitmapImage object using the FormatConvertedBitmap as the source? All the examples I've seen use the Uri of the image as the source.
Thanks!
|
|
|
|
|
Hi Guys,
Im using Xaml textbox,now i want to validate the textbox,like accepting only numbers or accepting only alphabets,i have referred some some site theres no clear solution.if anyone knows help me..
Regrds
Kanna..
|
|
|
|
|
Do you want to validate it, or do you want to prevent the user from being able to enter invalid information? If it's prevention, you can use the PreviewKeyDown event to prevent unwanted keypresses (by setting the Handled to true).
|
|
|
|
|
I followed the msdn d3dimage walkthrough on
msdn[^].
I used the August 2008 DirectX SDK, .NET 3.5 SP1, with Vista64SP1.
I made x86 and x64 binaries.
I set it up to have transparency (I need that).
It runs fine, with about 3% CPU on WinXP (x86). It's SP2, so I have WindowsXP-KB937106-x86-ENU installed to get the transparency to work.
On Vista however (what theoratically should run faster), I get 50% CPU, on both x64 and x86 binaries.
Bug in the platform?
One difference, is that the example uses Direct3DCreate9Ex on Vista and Direct3DCreate9 on XP (since Direct3DCreate9Ex should give better performance). Changing the code to always use Direct3DCreate9 didn't improve a thing.
Any help appreciated, Dave
The project (94kB zip, I left the binaries but cleaned up the rest) is over here: http://rapidshare.de/files/40349833/D3DWpfSprite.zip.html[^]
modified on Friday, August 29, 2008 1:54 PM
|
|
|
|
|
Hi All,
Couple of things really ... obfuscation for WPF, this has been really problematic since its been largely impossible to do this on a XAML application without bascially breaking it. An application called SmartAssembly has made some headway but I've just had an email from the Xenocode folks to say that Postbuild2008 now FULLY support Obfuscating XAML/.NET3.5 applications !!!!
http://www.xenocode.com/Products/Postbuild/[^]
Also, I've just found this on the Microsoft site that is making for some really interesting reading ...
Composite Application Guidance for WPF
http://msdn.microsoft.com/en-us/library/cc707819.aspx[^]
We're adopting this type of development for our WPF applications at the moment and its proving extremely effective.
|
|
|
|
|
|
Isn't it! Even though obfuscation is little more than a hurdle in the way of someone that wants the code real bad, its pretty much a requirement from manager types in terms of protecting IP.
|
|
|
|
|
Hi,
I will get a Set of results in a listbox. How can i enable a item by right clicking on it.. I would like to show a menu when user right clicks on the listbox item.
Santhapur
|
|
|
|
|
You can create your Context Menu in code or XAML and simply add it the ListBoxItem.ContextMenu property for each item.
Another way would be to add a Context Menu for the ListBox and perform hit testing for which ListBoxItem you are over.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
IF uou have any code snippet that would be helpful for me...
|
|
|
|
|
Do you want your context menu in XAML or code?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
either is fine with me... if you can send both thats too good
|
|
|
|
|
I hope that this helps:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns: d="http://schemas.microsoft.com/expression/blend/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="ListViewContextSample.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window.Resources>
<XmlDataProvider x:Key="WPFRSSFeed" d:IsDataSource="True"
Source="http://www.codeproject.com/WebServices/MessageRSS.aspx?fid=1004114"/>
<DataTemplate x:Key="itemTemplate">
<StackPanel>
<TextBlock Text="{Binding Mode=OneWay, XPath=title}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=description}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=link}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=author}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=pubDate}"/>
<TextBlock Text="{Binding Mode=OneWay, XPath=subject}"/>
</StackPanel>
</DataTemplate>
</Window.Resources>
<StackPanel x:Name="LayoutRoot">
<ScrollViewer IsTabStop="True" >
<ItemsControl ItemTemplate="{DynamicResource itemTemplate}"
ItemsSource="{Binding Mode=Default, Source={StaticResource WPFRSSFeed},
XPath=/rss/channel/item}">
<ItemsControl.ContextMenu>
<ContextMenu Name="MyContextMenu">
<MenuItem Header="This is my menu" />
</ContextMenu>
</ItemsControl.ContextMenu>
</ItemsControl>
</ScrollViewer>
</StackPanel>
</Window>
modified on Tuesday, September 2, 2008 5:05 AM
|
|
|
|
|
I have written like this..
<window x:class="WpfApplication2.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<grid>
<listbox height="70" verticalalignment="Top"> <listbox.contextmenu> <contextmenu>
<menuitem header="Send" click="MenuItem_Click">
<listboxitem>ListViewItem
This enables Contextmenu for the listBox. But i want to enable Context menu only for list box items...Is it Possible?
Santhapur
|
|
|
|
|
Santhapur - I can't see your code. Could you post it again using the < and > tags instead?
|
|
|
|
|
<Window x:Class="WpfApplication2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<ListBox Height="70" VerticalAlignment="Top">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" Click="MenuItem_Click"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBoxItem>Santhapur</ListBoxItem>
</ListBox>
</Grid>
</Window>
Santhapur
|
|
|
|
|
Santhapur - the easy way to do this is to blow the ListBoxItem open a bit. Consider the following bit that replaces the entry in the ListBox section.
<ListBoxItem>
<ListBoxItem.Content>
<TextBlock Text="Santhapur">
<TextBlock.ContextMenu>
<ContextMenu>
<MenuItem Header="Send" />
</ContextMenu>
</TextBlock.ContextMenu>
</TextBlock>
</ListBoxItem.Content>
</ListBoxItem> That should do it for you. The context menu is now associated with the textblock, which is the list box item.
|
|
|
|
|
|
You're welcome. Don't you just love WPF? So many ways you can do things - and easier to get at EXACTLY the thing you want to do, rather than having to fight your way through APIs.
|
|
|
|
|
I am using
<listBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
</grid>
</DataTemplate>
</ListBox.ItemTemplate>
</listBox>
I wrote context menu inside the Grid tags. But i am not getting the menu on it..
can any one help
|
|
|
|
|
HI
I have a .xaml file which contains view box which in tearn contains some graphics using WPF.Shapes. I have handdled few events (eg Click event of Path etc).
Now I want to shift this file in a resource and use in my user control. Is it possble to get the events definded in the xaml inside the user control and can I access the veiwbox form the xaml inside my user control?
|
|
|
|
|
Yes to everything, no problem. Works just like you are in a window.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl's Back!!!!! Wooo! Welcome fella!
|
|
|
|
|
It certainly is good to see the Molenator back, and now a Microsoftie - oh how I wish. Way to go Karl.
|
|
|
|