wpf

UserControl and binding paths--is it magic or logic?

I'm trying to confirm a binding behavior I believe I have observed, but I'm not exactly sure of. My original understanding was that a UserControl was sort of a black box, where if you wanted to share information back and forth with the controls contained within, you had to (1) use the DataContext or (2) define them on the surface of the...

DependencyProperty of Type Delegate

Hello, I have created an attached behavior that is used to execute a Delegate of type Func<bool> when the behavior is invoked. Below is the dependancy property definition. public static readonly DependencyProperty SendToDetailBehaviorProperty = DependencyProperty.RegisterAttached("SendToDetailBehavior", typeof(Func<bool>), typeof(ListD...

How do I apply a DataTemplate in a Dynamic Grid?

Hello, I have a Grid. The grid's columns are auto-generated at run-time based on the user's selection. I need the cells in the grid to be red if the content is a negative number. I have created a DataTemplateSelector. The DataTemplateSelector get's correctly called and returns my template if the cell is negative. Since my columns...

Playing videos in C# application via Windows Media Player. Is there a stable, decently performing solution?

I've written a WPF application (in Visual C# 2010 Express) that has 2 windows. The 1st has a various buttons, the other displays video using the MediaElement control. When a button is pressed, a video associated with it is played or stopped if it's already playing. On my development machine (Windows 7, good graphics card, lots of me...

How should I access the underlying entity/model of a ViewModel

Hi, We're designing a WPF / MVVM application that allows the user to search and manipulate contact records. We have a MainViewModel that contains an observable collection of ContactViewModel objects, each one of which wraps a Contact entity returned from our business layer. The UI displays these in a list, with the SelectedItem propert...

Unable To Bind VisualBrush's Visual To ViewModel

I have a TabControl whose ItemsSource property is bound to an ObservableCollection of ViewModels. What I want is to have a Rectangle whose Fill is a VisualBrush - and binding the VisualBrush's Visual to the SelectedItem of the TabControl. When I do this, I get a binding error stating: "'ObjectSourceConverter' converter failed to conve...

Adding new RenderTransforms to WPF Control

I've been messing around with the transforms option in WPF. How can I "add" a new transform to the existing one? I need to perform several different scalings from several different points at unknowable different times and simply add them on to the existing object, rather than re-creating a new transform with just the new scale in it. I'v...

WPF - Generic IValueConverter?

Hey all, I have a need to convert a number of different objects and I'd like to avoid writing a converter class for each one. Each of the objects inherits from a base class and I need to use the Id to get the Description (which is handled in my call to my CacheManager). For each class (I have about 30 of them) I have the following cod...

How to change SelectedItem in TabControl in animation?

When using Int32 animation like this <Int32Animation Storyboard.TargetName="stagesToGameTabControl" Storyboard.TargetProperty="SelectedIndex" From="0" To="1" BeginTime="0:0:8" Duration="0:0:0" /> when i click by my own on tabitems, raises exception InvalidCastException. Why it raises and how can i fix this? ...

Manipulating Custom User Controls Given Only (x,y) Screen Coordinates (without Mouse)

Given only an (x,y) point on the screen (without being allowed to use the mouse), how can you manipulate a custom UserControl? For example, I have a custom slider that I want to manipulate using only an x, y returned by a vision code (the vision code acts like a mouse, but I am not actually supposed to use the mouse). ...

Is there a way to apply a mask to the textbox of a DatePicker?

I'm working on my first WPF app. In this case, using VS 2010. My users are used to typing the date like this: "09082010" (without the double quotes; this would represent today). After they enter that, then it gets converted to 9/8/2010. I've put the DatePicker control onto the WPF page, but if the user enters 09082010, then it doesn't...

Draggable SelectionStart and SelectionEnd on WPF Slider?

I have a slider in my application with IsSelectionEnabled set to true and SelectionStart and SelectionEnd bound to properties of my ViewModel. This is working perfectly and shows the selected area in blue with marker triangles over the tick marks. Is there a way to have these marker triangles dragable so that the user can adjust the st...

Should a ViewModel in MVVM reference the View?

In the MVVM (Model-View-ViewModel) pattern should the ViewModel reference the view. I would think that it should not. But how should the following scenario be handeled? I have a view that has a tab control as the main container, the viewmodel for this view impliments a command to add a new tab to the tab control. The easy way would be to...

WPF - How to get a cell from a DataGridRow?

I have a data-bound DataGrid with alternating row background colors. I would like to color a cell differently based on the data it contains. I have tried the solution suggested by this thread http://wpf.codeplex.com/Thread/View.aspx?ThreadId=51143 But, DataGridCellsPresenter presenter = GetVisualChild(row) always returns null. I am...

WPF Firefox 4 Top Bar?

How would one create the top bar such as in Firefox 4's Orange bar? I don't want to do my own window class as I still want to be hardware accelerated rather than sofware rendered. Is there a way to do this? ...

WPF popup: how to make a reusable template for popups?

Since Popup doesn't derive from Control and doesn't have a template, how can I define a template so that all popups look the same? I need to design one that has a certain look and don't want to have to copy markup each time one is used. This seems pretty easy but I can't figure out how to do it. The Child property defines a logical tree...

WPF DataGrid: How do I set columns to TextWrap?

I'm not sure why my code isn't doing the TextWrapping properly. It doesn't wrap the text for the Description column (which is what I want). It just cuts it off and it doesn't even use the "..." to let me know there is more data. I tried to use this code I found online to do the job, but it didn't work. Ideally I'd love to be able to onl...

WPF FlowDocument Page Break/Positioning

Here's the situation. I'm tasked with auto-generating a rather large document consisting of a number of distinct sections of varying height and constant (full-page) width. Each section consists of two distinct sub-sections. Think of them as "header" and "data." The problem, then, is: When only one section fits on a page (because it ha...

Problems with ActualWidth not being recalculated...

How come ActualWidth of a DataGridColumn is not affected by changing the value of its Width property but it is when I change the value of its MinWidth ? In other words how does ActualWidth get computed or changed ? ...

WPF Combobox: Different template in textbox and drop-downlist

This is my combo-box. <ComboBox Height="45" HorizontalAlignment="Left" Margin="184,66,0,0" Name="ComboBox1" VerticalAlignment="Top" Width="216"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Label Content="{Binding FullName}" Width="150" /> ...