|
Hey guys,
I am using a WPF control in a library to generate a graphic and save that graphic with RenderTargetBitmap to a png file.
To generate the control-object, I use the new-operator. After setting some properties (background, with, height), I call BeginInit().
Then I am setting some properties, which set properties of the control within the usercontrol (the control in the usercontrol is a Chart-control of the WPF Toolkit). After setting the properties of the usercontrol, I am calling EndInit().
Before I use RenderTargetBitmap, I am calling Measure and then Arrange. This seems to render my user control, but the chart control within the user control seems not to update.
How do I force updating the control within the user control?
Post every idea you have.
Tell me, if you need some source code or more details.
Thank you!!!!
|
|
|
|
|
I found the solution.
I placed this inside my user control and call it before using the RenderTargetBitmap.
this.Measure(new Size(this.Width, this.Height));
this.Arrange(new Rect(new Size(this.Width, this.Height)));
BubbleChart.UpdateLayout();
|
|
|
|
|
Hi everyone, i wanted to know if someone here knows where could i find some tutorials to accomplish the following:
I want to make a silverlight app that shows in a main screen a pictures of a room, let´s say a living room, and i want to have a small menu at the left with a scroll bar with different things in it(different lamps, flowers, candels, etc.) and what i want to do is to drag and drop the desired element and place it into the main picture (living room).
Im pretty much a newbie so any tutorial that you can point at will be really usefull.
Thanks in advanced.
modified 6-Apr-22 21:01pm.
|
|
|
|
|
|
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
|
|
|
|