wpf

WPF design UserControl / DataTemplate problem

Hi! I have a question. I have a WPF UserControl representing a Person with many fields. Some Persons can be a company. In this case I'd like to use another template with other fields. The code behind is the same, that's why I want it as a 1 control only with 2 templates. What I'd like to do is to be able to define these 2 templates wi...

MVVM selecting a treeview item programmatically

It seems that others have had variations on this question, but from what I can tell it hasnt been addressed for folks using collections in a single view model. I have a VM that contains an ObservableCollection of objects, not a VM for each object. Therefore I dont think I can use the SelectedItem bool that is often discussed because I ...

WPF - TextBlock - Format Text Progrmatically

In the TextBlock object you can format the text in the XAML like this: <TextBlock> <Bold>bold text</Bold> random non bold next </TextBlock> How do you do the "Bold" tags programmatically? I tried just putting them in the text property and it just printed them out (the tags were printed as text). ...

Storyboard animation based on control template's control property

This is what I have A ControlTemplate for a button in my window.resource, having an ellipse with an outerglow (named -- TasksToggleButtonOuterGlowBitmapEffect) and a text A button that is using this template This is what I need 1. A storyboard that operates on the outerglow of the above mentioned ellipse 2. I shall trigger this sto...

WPF 3D - How can I save and load a Camera view?

I have a WPF 3D scene where I can pan, rotate and zoom using the TrackballDecorator from the 3DTools library. I would like to save the camera settings (transformation) and be able to re-apply them when the application restarts the next time (so the view is restored). I tried to save each individual value of the Camera: private void Sav...

WPF textbox binding issue.

I have a wpf window which is used to add as well as edit information about an entity. I am using mvvm architecture and ADO.Net entity model. The screen looks something like this - <!-- EmployeeView --> <Window .....DataContext={.....}> <WpfToolkit:Datagrid x:Name="dgEmployees" CanUserAddRows="fals...

MVVM - what is the ideal way for usercontrols to talk to each other

I have a a user control which contains sevral other user controls. I am using MVVM. Each user control has a corresponding VM. How do these user controls send information to each other. I want to avoid writing any code in the xaml code behind. Particularly I am interested in how the controls (inside the main user control) will talk to eac...

Grid and columnDefinition

I am having a Grid in WPF application. I want to display all the text block on the first column in the grid to be aligned to the right. so I thought I could do it with ColumnDefinition and Style like this: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition> <ColumnDefinition.Resources> <Style Targe...

How Can I Use the Visual State Manager in Blend for WPF Applications?

When creating a control style & template in Blend for a WPF application, I want to take advantage of the Visual State Manager. How do I do this? Whenever I right-click over the button and select Edit Template, Create Empty ... nothing shows up in the States panel. When I do the same for Silverlight application, the typical states show ...

WPF application fail to update the rectangle around the mouse pointer on click

Hi, Is it just me? I’m a WPF newbie. Everything is nice and shining, and I managed to write a small application that meets my needs, but I noticed that many times, for instance when I click a button or a list view, the event is handled (e.g. list view selection is changed), but the area under the mouse is not updated, so a small rectang...

Change a WPF image during a stroryboard

I was looking for a way to change an Image during a storyboard, or more specifically, change the Source property of the image to point to a new image resource. There seems to be a StringAnimationUsingKeyFrames and a DiscreteStringKeyFrame but this does not work (as far as I can tell) since the Source property of the Image is of type Imag...

WPF: Default TabControl's active tab overlaps from it's container, how to replicate this?

Hi, I am subclassing a control from TabControl (to be able to add stuff alongside tabs, like modern browsers do), and I encountered this problem: The active tab of native TabControl (1st and 2nd control from the top in the picture) overlaps the border of ContentPresenter, hiding the thin line underneath. I copied the xaml from Aero dic...

Elegantly override style of ComboBox's ToggleButton in WPF

I have a question regarding how to elegantly override an arbitrary element deep inside a control's visual tree. I also have attempted to resolve it in a few different ways, but I've run into several problems with each. Usually when I try three different paths and fail at each one I go downstairs, have a coffee, and ask someone smarter ...

Find control inside Listbox.ItemTemplate (WPF C#)

Hello I have some problem find right TextBlock control inside a StackPanel. My markup: <ListBox Name="lstTimeline" ItemContainerStyle="{StaticResource TwItemStyle}" MouseDoubleClick="lstTimeline_MouseDoubleClick"> <ListBox.ItemTemplate> <DataTemplate> ...

Drag and drop between two user controls

Hi, I have a user control which has a TreeView control in it as flowing... <Grid> <!-- Tree View --> <TreeView Name="devices" ItemsSource="{Binding Entities}" AllowDrop="True"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <EventSette...

Preventing WPF TreeView's GotFocus event from bubbling up the tree

I'm trying to write an event handler that fires every time a node in a TreeView gets the focus. The problem I'm running into is that the event handler fires on the TreeViewItem (node) that I click on with the mouse, and then it continues to bubble up the control tree, even though I've set e.Handled = true on the RoutedEventArgs provided...

CommandBinding Ctrl + Spacebar

I handle commands inside a RoutedCommand class that implements RoutedUICommand. This would help me to block or override a command by checking their CanExecute and Execute if needed. I can override EditingCommand, ApplicationCommand, etc.. One of the command that I cannot even handle is Ctr + Spacebar. Is it a MediaCommand or some other t...

Has anyone developed an editor / ide using C#/Silverlight/WPF?

We are currently developing a web application in ASP.NET MVC which would really benefit from a IDE of sometype to help allow some elements to be visually customised. Could anyone recommend an approach ? We are thinking of maybe a plugin using Silverlight. Does anyone have any links or examples that might help ? ...

Event handler in DataTemplate

I have WPF ComboBox inside a data template (a lot of comboboxes in listbox) and I want to handle enter button. It would be easy if it was e.g. a button - I would use Command + Relative binding path etc. Unfortunately, I have no idea how handle key press with a Command or how to set event handler from template. Any suggestions? ...

Control user input to textfields

Looking for a way to control user input in text fields. i.e. one field can be double, one field string, one field int. Is there a library I can use to look after this for me? Using: Vs 2008, C#, WPF ...