wpf

What does InitializeComponent() do, and how does it work? (WPF)

What does InitializeComponent() do, and how does it work? (WPF) In general first, but I would especially be interested to know the gory details of order of construction, and what happens when there are AttachedProperties. ...

Size-to-content-layout problem in WPF

This is supposed to be a no brainer but I still can’t figure it out. In my sample app there’s a button and a textbox in a dockpanel. If the content of the textbox is smaller than the content of the textbox the window is as big as it needs to be to display the content of the button. That’s what I want. But if I put more text into the tex...

Best practices for storing UI settings?

hi there, we're currently planning a larger WPF LoB application and i wonder what others think being the best practice for storing lots of UI settings e.g. Expander States Menu orders Sizing Properties etc... i don't like the idea of having dozens of stored values using the delivered SettingsProvider (i.e. App.config file) although ...

WPF ComboBox SelectedValue not updating from binding source.

Here's my binding source object: Public Class MyListObject Private _mylist As New ObservableCollection(Of String) Private _selectedName As String Public Sub New(ByVal nameList As List(Of String), ByVal defaultName As String) For Each name In nameList _mylist.Add(name) Next _selectedName = defaultNam...

How do I build a DataTemplate in c# code?

I am trying to build a dropdown list for a winform interop, and I am building the dropdown in code. However, I am having a problem getting the data to bind based on the DataTemplate I specify. What am I missing? drpCreditCardNumberWpf = new ComboBox(); DataTemplate cardLayout = new DataTemplate {DataType = typeof (CreditCa...

WPF Trigger for IsSelected in a DataTemplate for ListBox items

Hi, I have a listbox, and I have the following ItemTemplate for it: <DataTemplate x:Key="ScenarioItemTemplate"> <Border Margin="5,0,5,0" Background="#FF3C3B3B" BorderBrush="#FF797878" BorderThickness="2" CornerRadius="5"> <DockPanel> <DockPanel DockPanel.Dock="Top" Margin="0,2,0,0"> ...

Can I control which nodes are selectable in a WPF TreeView?

I have a two-level hierarchy displayed in a WPF TreeView, but I only want the child nodes to be selectable - basically the top level nodes are for categorisation but shouldn't be selectable by themselves. Can I achieve this? Thanks... ...

Setting DataContext with SelectedItem Programatically

How do you programatically set a DataContext that specifies the selected item of a list? More simply, how do you reproduce this type of binding in code? <StackPanel> <ListBox Name="listBox1" /> <TextBox Name="textBox1" DataContext="{Binding ElementName=listBox1, Path=SelectedItem}" /> </StackPanel> ...

WPF visual state manager in Blend 2 sp1

Can anyone explain to me how to get the visual state manager to work with a WPF application? It's just been added to the new wpftoolkit. I installed it as told, but even the sample doesn't show the VSM. In silverlight it work, but not in WPF. If installed the latest Blend 2 and updated with the SP1. ...

WPF: How to apply a GeneralTransform to a Geometry data and return the new geometry?

Having some Geometry data and a Transform how can the transform be applied to the Geometry to get a new Geometry with it's data transformed ? Ex: I Have a Path object that has it's Path.Data set to a PathGeometry object, I want to tranform the points of the PathGeometry object in place using a transform, and not apply a transform to the...

How do I add icons next to the nodes in a WPF TreeView?

I have a WPF TreeView with just 1 level of items. The TreeView is data bound to an ObservableCollection of strings. How can I ensure that the same icon appears to the left of each node in the TreeView? ...

MouseOver highlighting style returning to default after a second (Caused by Aero?)

I'd trying to style my ComboBoxes to match the rest of the UI but I'm having problems with the IsMouseOver highlighting. It highlights with the color I specify for a second and then fades back to the default color, kind of a cool effect but not what I'm going for. Here is my style: <Style TargetType="ComboBox"> <Style.Triggers> ...

How to modify Expander button background only? WPF

I have an Expander placed on a window with a blue background and I would like to make the button for the expander another color than the default (blue, which it is receiving from the window). When I modify the background property of the expander it changes the entire expander, header and all to the new color. However, I would like only...

How do you bind the TextWrapping property of a TextBox to the IsChecked value of a MenuItem?

The TextWrapping property of the TextBox has three possible values: Wrap NoWrap WrapWithOverflow I would like to bind to the IsChecked property of a MenuItem. If the MenuItem is checked, I want to set the TextWrapping property of a TextBox to Wrap. If the MenuItem is not checked, I want to set the TextWrapping property of the TextB...

WPF ComboBox Item tabbing behaviour

I am migrating some win forms panels to WPF. In WinForms, you can tab into to the combo box using the keyboard, select an item by typing the first character and then hit tab again and the combo to lose focus. In WPF the second tab will move the focus rectangle down the list, instead of moving onto the next control. Is there a way to g...

Silverlight, Wpf Web App (xbap) or Click Once? Pros and Cons

We are starting a new project and I'm trying to decide which of the Wpf-esque develop/deploy strategies we should go with. In our case we are looking at quite a complex business app that will be used by 100s (not 1000s) of people, So I'm leaning towards a click-once app. My boss likes the idea of a Silverlight app as it means easier depl...

A better way of forcing data bound WPF ListBox to update?

Hi,, I have WPF ListBox which is bound to a ObservableCollection, when the collection changes, all items update their position. The new position is stored in the collection but the UI does not update. So I added the following: void scenarioItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChange...

Is it appropriate to use "Wingdings" fonts in a Windows Forms or WPF app?

I have a WPF control, that has a list of "Investors", and in the right column of the list, a "Delete" button. I could either waste some time making an image of an "x" in photoshop. Or, I could just use Wingdings font and set the content to "Õ" (which makes a cool looking delete button). Is this appropriate? My thinking is... while not ...

In a WPF app, is there a object I can assign to FileSystemWatcher.SynchronizingObject?

In a WPF app, is there a object I can assign to FileSystemWatcher.SynchronizingObject? I can make my own, but if there is one available, I would like to use it. ...

Change the coordinate system of a Canvas in WPF.

I'm writing a mapping app that uses a Canvas for positioning elements. For each element I have to programatically convert element's Lat/Long to the canvas' coordinate, then set the Canvas.Top and Canvas.Left properties. If I had a 360x180 Canvas, can I convert the coordinates on the canvas to go from -180 to 180 rather than 0 to 360 on...