wpf

How to get a ListView (or DataGrid) work with TextWrapping (WPF)

I mean, i have one of this controls and text inside one of it's columns. Usually if user changes column size, it's just cutting text. If I'm trying to use template with textblock or textbox and set TextWrapping="Wrap" inside of the template - it's really doesn't change anything. What's the way out? *And yes, I searched before asking, an...

Tabbed Interface in C#/WPF

I am currently working on an application with a tabbed interface. I want to be able to split the workspace horizontally or vertically by dragging a tab to one edge of the window. For example, open two tabs: http://666kb.com/i/b65vvbusbxhvgy8mf.png Then drag one tab to the bottom of the screen and drop it. A second tabcontrol should app...

How do I make Binding respect DependencyProperty value coercion?

I have a control with a DependencyProperty with a CoerceValueCallback. This property is bound to a property on a model object. When setting the control property to a value that causes coercion the Binding pushes the uncoerced value to the model object. The property value on the control is coerced correctly. How do I get the Binding to ...

WPF Binding relational ComboBox's from L2S with filtering on all of them.

Hi, in a WPF project with Linq to SQL, if you use the O/R - designer to create a simple structure with 3 that are all tied with forgin key relataions like so: Customer <-- Orders <-- Items, and say i want a simpe window with 3 syncronized comboboxes when you select a customer you see only his orders and when you select an Order you see...

What is the "Weak Event" pattern used in WPF applications?

The WindowsBase DLL defines the IWeakEventListener event with summary: Provides event listening support for classes that expect to receive events through the WeakEvent pattern and a System.Windows.WeakEventManager. This vague description doesn't describe what the 'WeakEvent pattern' actually is. So, what is this pattern, why is it...

How can I hide the selected item in a WPF combo box?

I want to hide the selected item from the opened WPF combo box, basically to show instead of this: item2 item1 item2 item3 this: item2 item1 item3 How can this be done? ...

How do I set TargetNullValue to a date?

I'm using the WPF toolkit's Calendar control to allow users to select a date. If the date is not yet selected then the property the SelectedDate is bound to is Null. This makes the Calendar default you January 1, 0 AD. I'd like to do something like SelectedDate="{Binding UserPickedDate, TargetNullValue=Today, Mode=TwoWay}" But both "T...

WPF C# - Change the brush of a menu's background

Does anyone know how to change the brush for a menu's background? This sounds simple, but I don't see any obvious way to do this. You'd think that the Background property would change it, but it doesn't. Here's what my menu looks like (notice the default white background): Example Image Example Code: <Window.Resources> <Soli...

How to handle the mouse wheel click event in WPF?

I want to close a tab in my tab control when the mouse wheel is clicked. How can I capture this event in WPF? EDIT: Here's the code: private void tabMain_MouseDown(object sender, MouseButtonEventArgs e) { if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed) { MessageBox...

<ColumnDefinition Width="*" /> not respected in DataTemplate

I have a WPF ListBox with a defined DataTemplate. In that template, I have a grid, where the first column width should take up all remaining room in the grid. This seems to work outside the ListBox, but not inside. Why is that, and how can I get it to behave the same? Here is my code. See line 36, and line 70 <UserControl x:Class="Ru...

Will you migrate your UI to using ribbons for Windows 7?

Soon Windows 7 will use ribbon as default interface in any Windows programs, like Paint or WordPad, leaving to back default toolbars and menus. Will you migrate your UI to using ribbons for Windows 7? ...

Why can't I select a null value in a ComboBox?

In WPF, it seems to be impossible to select (with the mouse) a "null" value from a ComboBox. Edit To clarify, this is .NET 3.5 SP1. Here's some code to show what I mean. First, the C# declarations: public class Foo { public Bar Bar { get; set; } } public class Bar { public string Name { get; set; } } Next, my Window1 XAML: ...

Issues calling Dispatcher in WPF

I have some UI code that needs to be updated from my background presenter thread. So, I do the following: from my background thread, I set my property in the UI: _ui.ConnectionStatus = "A"; then, my set is as follows: public string ConnectionStatus { set{ if (Dispatcher.CheckAccess()) ConnectionStatusTxt.Content = value; else { ...

Force a custom WPF Control to resize correctly

I have written a WPF user control and part of it involves dynamically adding elements to a canvas which effects the height of said canvas. The canvas is nested within a grid. When I dynamically add my elements the height of the canvas changes, but the canvas ends up extending beyond the edge of the overall control rather than causing the...

Make async event synchronous in JavaScript

I'm using the WPF 3.5SP1 WebBrowser control to display a page containing some javascript functions. My program then needs to invoke a javascript function which will make an asynchronous call. I need a way to get the result of that asynchronous call back to C# so I can process the result. Is there a way I can make the first javascript fu...

Changing the template of a TreeViewItem when it is selected

I'm having some problems changing the DataTemplate that is used for a TreeViewItem when it is selected. Ideally, I would like each item to contain a TextBlock, and then when selected it should contain a TextBox instead. Here is what I have so far (I used this question as a starting point): <Window> <Window.Resources> <Hiera...

Projecting a 3D point to a 2D screen coordinate

Based on information in Chapter 7 of 3D Programming For Windows (Charles Petzold), I've attempted to write as helper function that projects a Point3D to a standard 2D Point that contains the corresponding screen coordinates (x,y): public Point Point3DToScreen2D(Point3D point3D,Viewport3D viewPort ) { double screenX = 0d, screenY = 0...

Beginner's guide to 3D graphics programming

What are the best guides / tutorials / books / websites for someone with minimal experience (or none) in the world of 3D graphics programming? I realize that the fundamentals of 3D graphics and mathematics apply across platform specific 3D library implementations such as OpenGL, DirectX, WPF etc.. Therefore it would be useful if answer...

WPF PresentationSource.FromVisual Element within Style

I have custom Bitmap object that is within a styled button. I am trying to call PresentationSource.FromVisual within the Bitmap object however it is returning null. How would I get the Parent element (in this case a Button) from within the child Bitmap object. Is there standard code to get the styled parent? For example the WPF style...

StringFomat Localization problem

Hi In WPF 3.5SP1 i use the last feature StringFormat in DataBindings: <TextBlock Text="{Binding Path=Model.SelectedNoteBook.OriginalDate, StringFormat='f'}" FontSize="20" TextTrimming="CharacterEllipsis" /> The problem i face is that the date is always formated in...