wpf

Snap to Object/Control feature

Hi, i am doing an editor kind of project application in wpf in which i am allowing user to drag their controls (i have defined my own controls that allows user to customize their screens) to the Canvas window i.e I have toolbar and canvas area.i have placed controls in the toolbar and those controls can be dragged and dropped on the can...

Running a C#/WPF application on a Mac

I sell a C#/WPF application (targeting .net 3.0 at the moment) and people keep asking me for a Mac version. The application is a time tracking application with a good GUI, there isn't that much business logic in a time tracking application so most of the application is GUI - rewriting just the GUI is equivalent to rewriting the entire a...

How to bind to an Image using a dynamic URL in WPF?

I am new to WPF so hopefully I phrased the question correctly. What I'd like to do is bind my <Image> to an image online. However, the image I would like to bind to changes depending on the state of the application. For example, if I wanted to bind to an Employee selected from a list, I'd retrieve a base URL from my App.config and append...

How to restyle a control nested in a custom control?

Suppose that you are developing a custom control in WPF that contains internally some other basic controls. To keep it simple suppose that it contains 2 buttons. Now you want to use this custom control in your app, but you want to restyle it a bit. CASE 1 If, in the custom control definition, both buttons have the same style (wpf defa...

Binding to a command in a datagrid

I am using the M-V-VM pattern in a WPF app. I am binding a ViewModel to a COntentControl and using a data template defined int eh window resources to render the view (a UserControl) for that ViewModel. In the ViewModel, I have a collection of items. I'm binding that collection to the data grid provided in the WPF toolkit. Also in the...

WPF: Getting new coordinates after a Rotation

With reference to this programming game I am currently building. To translate a Canvas in WPF, I am using two Forms: TranslateTransform (to move it), and RotateTransform (to rotate it) [children of the same TransformationGroup] I can easily get the top left x,y coordinates of a canvas when its not rotated (or rotated at 90deg, since ...

How can I give a WPF element a rectangular flat 3D border?

I would like to create a rectangular 'flat 3D' look for one of my control templates. In it's most simple version this means having a line at the bottom that is darker than that at the top, and maybe some variation between the left and right lines too. A more complex version would allow me to provide on or more brushes so that gradients...

WPF Databinding in XAML

Hello I have little problem with databinding in my current project. I have an ObservableCollection I want to bind to an ListBox. public ObservableCollection<GeoDataContainer> geoList = new ObservableCollection<GeoDataContainer>(); ...later... geoListBox.ItemsSource = geoList; This code works fine. The Listbox has a datatemplate an...

TextBlock data-bound to Singleton not updating in WPF

Hello. I apologize for the newbie question, but I am struggling with this problem. I have the following TextBlock defined: <TextBlock Text="{Binding Source={x:Static local:DeviceManager.Instance}, Path=Player.CurrentArtist}"></TextBlock> The DeviceManager is a singleton that functions as a facade for other classes. For example, Play...

Arrange GUI elements in WPF in a similar way to the applications on the iPhone

I would like to arrange UIControls in WPF in a similar way to the applications on the iPhone. They should be positioned on a grid, but a user should be able to drag them somewhere else, after releasing the mouse button (or the finger in case of an iPhone) the selected UIControl should snap back to the next position in the grid. The other...

Getting the path of a ClickOnce File Association

I've using ClickOnce and I'm struggling with file associations. I can set up the association. Double-clicking an associated file even launches the application. ...However... I don't know how to get access to the path of the file clicked to launch the App. Has anyone come across this before? ...

How can I bind data to the contents of a Run?

I want to construct a TextBlock consisting of several Run elements, with their contents bound to string variables, but Visual Studio complains, saying that one can only bind to a dependency property, which Run.Text isn't. Is there anything that can be done? ...

Can I find Logical Children by Type

I know i can use LogicalTreeHelper class to find children node for every element searching it by name. But is there a possibility to find a child node by Type? For example, what if i would like to find a ListBox element in my Window without knowing its Name property?? ...

WPF RichTextBox and specific culture issues

Hi there, Im trying to set Language for System.Windows.Control.RichTextBox as "es-PE", but I found some issues, for example in some computers, works perfectly and SpellChecker is enabled with "es-PE" language, but in others it just works with "en-US", so I Dont know whats the matter with that control, I was using the following code in...

Load a byte[] into an Image at Runtime

I have a byte[] that represents by Image. I am downloading this Image via a WebClient. When the WebClient has downloaded the picture I reference in via a URL, I get a byte[]. My question is, how do I load a byte[] into an Image element in WPF? Thank you. Note: This is complementary to the question I asked here: http://stackoverflow.com...

Load byte[] into a System.Windows.Controls.Image at Runtime

I have a byte[] that represents a .png file. I am downloading this .png via a WebClient. When the WebClient has downloaded the .png I reference via a URL, I get a byte[]. My question is, how do I load a byte[] into a System.Windows.Controls.Image element in WPF? Thank you. Note: This is complementary to the question I asked here: http:/...

What are the issues with running WPF across multiple AppDomains on one UI thread?

We are looking at creating a WPF UI that runs across multiple AppDomains. One of the app domains would run the application while the remaining AppDomains would host a series of user controls and logic. The idea, of course, is to sandbox these User Controls and the logic away from the main application. Here is an example of doing this us...

Can I color different parts of text in a WPF TextBox?

I've got a WPF TextBox into which my users type XHTML. XAML... <TextBox Name="TextBoxContentBody" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" FontFamily="Consolas" ... /> It looks like this: I'd rather that it looked like this (Photoshopped mock-up): ...

WPF - Set DataTemplate for programmatically added GridViewColumns

Hi all, Couldn't find an answer to this one. I have a WPF ListView control that can contain varying number of columns. For example, it can display customer data, displaying columns Id, Name, Email etc, or it can contain products, displaying ID, Name, Price, NumberInStock, Manufacturer, well, you get the idea: varying number of columns,...

Animation inside an adorner (calling OnRender)

I'm using an Adorner in .NET 3.5, and I'm able to draw by overriding OnRender, but I need the ability to redraw the adorner to change its appearance. Essentially I'm looking for a way to clear the drawing context and call OnRender again. What's the best way to do this, or is there a better approach? public class MyAdorner : Adorner { ...