|
|
Hi guys!
Is there a chance to find out, whether a button was right or left clicked by using commands?
What I would like to do is add to commands to a button, one for left click and one for right click.
Thanks in advance!
|
|
|
|
|
You can add a MouseBinding(or MouseGesture).
Something like this,
<MouseBinding Gesture="LeftClick"
Command="ApplicationCommands.Open" />
MouseBinding needs the Mouse action and the routed command to be executed. You will have to add another MouseBinding for Right-click and also change the Command value to the routed command to be executed in your case.
For more details, see here[^], here[^] and here[^]
|
|
|
|
|
|
I have done something like that before. I put it in a custom control since the basic button class does not seem to provide such functionality.
Hmmmm... sounds like an article that should be written...
|
|
|
|
|
You can do it with a MouseBinding. Did you see my suggestion[^] ?
|
|
|
|
|
I did not see your reply until after I posted mine (nor did I consider the possibility of putting input bindings on individual controls instead of the window). Since I already have a solution working, I think I will stick with it. Plus, I prefer to write this:
<TextBlock controls:DualCommandProvider.LeftClickCommand="Open"
controls:DualCommandProvider.RightClickCommand="Close" />
instead of this:
<TextBlock>
<TextBlock.InputBindings>
<MouseBinding Command="Open" MouseAction="LeftClick" />
<MouseBinding Command="Close" MouseAction="RightClick" />
</TextBlock.InputBindings>
</TextBlock>
Especially since where I am using this, I am putting left and right click actions on many controls and the extra lines would make the flow of the design harder to follow.
|
|
|
|
|
I have a different opinion though. I feel separating it into a different section would make it easier to follow. It would demarcate the properties and bindings into separate group instead of all of them being together. It looks neat with just two entries but I would go crazy when the properties/bindings set through XAML would increase and make the node look ugly.
This method has the obvious advantages of inherent implementation and access to all Mouse gestures in addition to the left and right click.
But hey, as you feel comfortable. Cheers
|
|
|
|
|
Hi.
I have a wpf app that have a stack panel that i would like to populate
with images that i'm downloading from a website.
to avoid getting the UI from freezing while downloading the images i created another thread and in that thread downloaded the images and tried to create the image controls. but i'm getting this exception:
"The calling thread must be STA, because many UI components require this."
Here is the thread code:
<br />
new Thread(delegate()<br />
{<br />
string searchUrl = siteAlgorithm.BuildSearchExpression(searchKeyWords);<br />
searcherObj.Clear();<br />
searcherObj.LoadNewPage(siteAlgorithm.ExtractSearchResults(myWebClient.DownloadSiteToString(searchUrl)));<br />
<br />
MemoryStream stream;<br />
Image img = new Image();
System.Windows.Media.Imaging.BitmapImage bitImg;<br />
foreach (SearchResult item in searcherObj.FirstPage.resultItems)<br />
{<br />
stream = new MemoryStream(myWebClient.DownloadData(item.imageUrl));<br />
<br />
bitImg = new System.Windows.Media.Imaging.BitmapImage();<br />
bitImg.BeginInit();<br />
bitImg.StreamSource = stream;<br />
bitImg.EndInit();<br />
img.Source = bitImg;<br />
<br />
Gui.AddSearchResultItem(img, item.info, item.uri);<br />
}<br />
}<br />
).Start();<br />
|
|
|
|
|
You can't create controls from another thread. You CAN use the background worker class to download them, and it's work finished delegate runs on the main thread, as does the progress event, so you can use those to put your image into your page.
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.
|
|
|
|
|
Hi all,
I want to create a simple form contains two combobox and a button.
1.ComboBox 1: Select which program the client wants to join.
2.ComboBox 2: Select which group of client will join the program
3.Button 1: When Clicked, I need find all the client in that selected group then insert into Join table.
I want to know how to write that custom method to insert all those entries.
Any example which I can study and learn to fulfill my goal?
Thanks.
|
|
|
|
|
I want the foreground color to be a bright color (the background color is black) and when the menu item is selected, a bright color gets washed out by the selection highlight. I don't see a property anywhere for changing the selection background color.
|
|
|
|
|
I have the same proplem, and can't find the solution.
Please send it for me, if you find it out!!
Thanks!
|
|
|
|
|
How setting menu selected Backcolor and menu selcted forecolor incode c#
|
|
|
|
|
What have you tried ? What does MSDN say ?
If you give your menu or menu item an x:Name, then you can access it's properties in the code behind.
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.
|
|
|
|
|
I have a situation where when focused on a tab in a tabcontrol I may want to navigate the visual tree for the content in another tab however I am unable to do this since it has been unloaded (due to it's tab not being focused). Is there anyway I can force the visual tree to load?
|
|
|
|
|
You can do better than that. Have a look at this[^] post from Eric Burke.
"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 am working on a silverlight application. In this I have to change the background color of canvas dynamically. For this I used this
Canvas1.Background=new SolidColorBrush(Colors.Gray);
But I want to assign some custome color like #A1A1A1
For this I tried
Canvas1.Background = new SolidColorBrush(Color.FromArgb(........
But I am not get the actual color
If anyone have any idea to do this please reply me.
Thanks in Advance
|
|
|
|
|
#A1A1A1 is not an ARGB colour - it's an RGB colour. The A refers to the opacity of the color (it means Alpha), and this needs to be appended to the front, so a solid color would be #FFA1A1A1.
"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
|
|
|
|
|
Is this message board a correct place to ask remoting and webservices related doubts?
|
|
|
|
|
No,but kudos for taking the time to find out. If you wanted to ask about how WCF worked, this would be the place. Depending on what you want to know, you should look at the C# (or VB.NET) forum, the .NET forum or the ASP.NET forum for pure web service help.
"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 am working on silverlight project. In this I designed Page.xaml and called it in a aspx page. But now when I run the application for small size monitors it is displaying a part of the page and cannot view remaining page. Aslo I am not even getting scroll bar for the page to view the whole content of the page. For large size monitors it is displaying all the content in the page.
Please reply me how can I change sttings to display scroll bars to view all the content.
Thanks in advance.
|
|
|
|
|
You could wrap your root element in a ScrollViewer element.
MArk
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Question was: how do I convert a hex string to a Media.Color, with the hope that .Net 3.5 was mature enough to provide a method.
I found the solution and wanted to delete the thread...
1) add a reference to System.Drawing
2) System.Drawing contains overloaded fromArgb() so that I don't have to bit-shuffle
EDIT: but this approach didn't work...
modified on Wednesday, September 16, 2009 8:43 PM
|
|
|
|