wpf

Reset Expander to default collapse behavior

I'm using an expander inside a Resizer (a ContentControl with a resize gripper), and it expands/collapses properly when the control initially comes up. Once I resize it, the Expander won't properly collapse, as documented below. I ran Snoop on my application, and I don't see any heights set on Expander or its constituents. How would...

Setting the scrollbar position of a ListBox

Can I programatically set the position of a WPF ListBox's scrollbar? By default, I want it to go in the center. ...

What are the limitations of Loose XAML?

I have been experimenting with WPF and rendering strict XAML markup in a web browser, also known as Loose XAML (explained here and here). It strikes me as mostly useful for displaying static content. However, it also appears possible to bind to an XML data provider. Loose XAML files are not compiled with an application, which create...

ListBox with Grid as ItemsPanelTemplate produces weird binding errors

I've got a ListBox control and I'm presenting a fixed number of ListBoxItem objects in a grid layout. So I've set my ItemsPanelTemplate to be a Grid. I'm accessing the Grid from code behind to configure the RowDefinitions and ColumnDefinitions. So far it's all working as I expect. I've got some custom IValueConverter implementations fo...

No output to console from a WPF application?

I'm using Console.WriteLine() from a very simple WPF test application, but when I execute the application from the command line, I'm seeing nothing being written to the console. Does anyone know what might be going on here? I can reproduce it by creating a WPF application in VS 2008, and simply adding Console.WriteLine("text") anywhere ...

Experience with CSLA in a WPF/WCF application

Has anyone used CSLA in an application that has a WPF front end and a WCF wire for entities? If so, which "entity framework" did you use? (nHibernate, Linq, etc...) What were the hang-ups? What did it help you with? I am concerned with implementing this for an application, not knowing how data-binding, validation with UI/entities, or ...

WPF: Slider doesnt raise MouseLeftButtonDown or MouseLeftButtonUp

I tried this XAML: <Slider Width="250" Height="25" Minimum="0" Maximum="1" MouseLeftButtonDown="slider_MouseLeftButtonDown" MouseLeftButtonUp="slider_MouseLeftButtonUp" /> And this C#: private void slider_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { sliderMouseDown = true; } private void slider_MouseLeftButtonUp(obje...

Can a WPF ListBox be "read only"?

We have a scenario where we want to display a list of items and indicate which is the "current" item (with a little arrow marker or a changed background colour). ItemsControl is no good to us, because we need the context of "SelectedItem". However, we want to move the selection programattically and not allow the user to change it. Is t...

WPF Bind to a Collection of objects, sorted by IDs stored in order in another Collection in C#

For those of you that like puzzles: I had this problem recently and am sure there must be a nicer solution. Consider : an ObservableCollection of Foo objects called foos. Foo contains a string ID field I have no control over foos foos will be changing Then: I have another collection called sortLikeThis sortListThis contains string...

Is there a good iTunes coverflow-type control for WPF?

I am currently using Telerik's carousel control, but it is lacking many features and is buggy. Is there a good control out there that looks the the coverflow control in itunes? ...

How does ItemContainerGenerator.ContainerFromItem work with a grouped list?

I have a ListBox which until recently was displaying a flat list of items. I was able to use myList.ItemContainerGenerator.ConainerFromItem(thing) to retrieve the ListBoxItem hosting "thing" in the list. This week I've modified the ListBox slightly in that the CollectionViewSource that it binds to for its items has grouping enabled. Now...

Rich Text in Windows Forms application

I would like to update a Windows Forms application to provide the following features: spell checking limited formatting of text: bold, italics, bulleted lists Ideally the formatted text could be accessed in a plain text way for reporting through tools that don't support the formatting, but could also be rendered as HTML for tools tha...

What functional differences exist between WPF and WinForms WebBrowser control?

WPF WebBrowser control looks great but knowledge accumlated over time about WinForms WebBrowser is substantial and it's hard to ignore work like csExWB. It would be nice to know what functional shortcomings or advantages exists in .NET 3.5's WPF WebBrowser control over WinForms WebBrowser control. In particular, is it possible to build c...

How do you make a WPF slider snap only to discrete integer positions?

The title says it all. All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of old. That is, I want a slider that goes from X to Y but only allows the user to move it in discrete integer positions. How does one do this in WPF since the Value property on the Slider is double? ...

Learning Windows Forms vs. Windows Presentation Foundation

So I've been thinking of going for Microsoft certification and I have to make a choice (for now) between Windows Forms and WPF for developing Windows applications. I have had good exposure to Windows Forms but never tried WPF before. Furthermore, most of the job postings where I live seem to be WinForms-oriented. That might change in the...

How do I make modal dialog for a Page in my WPF-application?

I have a WPF Window which has a among other controls hosts a Frame. In that frame I display different pages. Is there way to make a dialog modal to only a page? When I'm showing the dialog it should not be possible to click on any control on the page but it should be possible to click on a control on the same window that is not on the pa...

WPF Data Binding and IValueConverter

Why is it that when I use a converter in my binding expression in WPF, the value is not updated when the data is updated. I have a simple Person data model: class Person : INotifyPropertyChanged { public string FirstName { get; set; } public string LastName { get; set; } } My binding expression looks like this: <TextBlock Text="{B...

Can I save a FlowDocument to BAML in a programmatic way?

Has anyone found a way to save a FlowDocument as BAML or other compressed format? I can import XML with images to create a new FlowDocument: <TextRange class instance>.Load(fs, DataFormats.Rtf) However, I haven't found a good way to save it in a 'native' compressed format. Uncompressed XAML is easy to generate using: <TextRange cla...

Can you use routed events with a MultiTrigger?

Does WPF support using a triggers that respond to routed events but only given a condition is met? For example, WPF supports triggering on routed events through Event Triggers. ie: <Button> <Button.Triggers> <EventTrigger RoutedEvent="Click"> ... </.. </.. </.. However I am looking for the trigger to go off only giv...

Autocomplete Dropdown - too much data, timing out

So, I have an autocomplete dropdown with a list of townships. Initially I just had the 20 or so that we had in the database... but recently, we have noticed that some of our data lies in other counties... even other states. So, the answer to that was buy one of those databases with all towns in the US (yes, I know, geocoding is the answe...