wpf

WPF - Is there a good reason that Setter.Value isn't a ContentProperty?

Every time I write out a setter whose Value property value isn't describable inline, I curse the fact that the API doesn't mark the Setter class with [ContentProperty("Value")], which would allow this: <Setter Property="BitmapEffect"> <Setter.Value> <OuterGlowBitmapEffect GlowColor="#AAC" Opacity="0.2" GlowSize="1.25" /> </Sette...

WPF - Dynamic tooltip

I have a class ToolTipProvider which has a method string GetToolTip(UIElement element) which will return a specific tooltip for the UIElement specified, based on various factors including properties of the UIElement itself and also looking up into documentation which can be changed dynamically. It will also probably run in a thread ...

WPF column resize performance issues

Are there in general any known performance issues in WPF related to grid column resizing? I have an application where I need to do some particular things in a column, but for all the different solutions I find the column resizing gets slow. This applies when I have typically more than 1000 elements in my list, but I assume this isn't t...

c# / WPF : Make a Browse for File Dialog

I'm new to WPF and am trying to make my first WPF desktop application using VC# Express. I'm trying to get make three open file dialogs complete with text fields that show the specified path if the user chooses a file. I found working code to make the dialog box appear at the click of a button, but how do I get a text field to update/bi...

How to pass parameters to the command object from Xaml for the button tool?

How to pass parameters to the command object from Xaml for the button tool? <igRibbon:ButtonTool Id="btnFindEntity" Caption="Search" LargeImage="Images/Search.png" igRibbon:RibbonGroup.MaximumSize="ImageAndTextLarge" Command="{Binding RibbonSearchCommand}"/> Please help me with the above code.. I have to pass a combo box and a text bo...

How to show a flowdocument in multiple pages like Word?

I have an project that is much like MS Word and needs to display and Edit a range of pages with contains Rich text and want to show this content onscreen in multiple rich-text-box controls that are stacked vertically and scrolled to create the effect of document flow. Also i would like the content to flow automatically between the contr...

How do I host WPF content in MFC Applications?

I'm going to answer my own question here because I spent a few hours piecing this together and wanted to share what I found in the hope that I will save someone else the digging. There is an MSDN Walkthrough that gets you most of the way there, but there are a couple of key pieces that I found elsewhere. For example, the walkthrough te...

[WPF] Calculating number of visible items in ListBox

I have a class called Book; class Book { public string Name { get; set; } public string Author { get; set; } public int PagesCount { get; set; } public int Category { get; set; } } The ListBox displays a list of Books and the ItemTemplate has been modified so as to visually represent the Book. The text shows the book's Name, autho...

How do I get the header content for a DataGridColumnHeadersPresenter control template?

<dg:DataGridColumnHeadersPresenter> <dg:DataGridColumnHeadersPresenter.Template> <ControlTemplate> <Border> <ContentPresenter ContentSource= ??? /> </Border> </ControlTemplate> </dg:DataGridColumnHeadersPresenter.Template> </dg:DataGridColumnHeadersPresenter> Thanks for yo...

Unable to retrieve TIFF pages from TiffBitmapDecoder.Frames -- all frames are page 1

I'm trying to convert a multipage tiff image into a multipage XPS document. The problem I'm having is with the TiffBitmapDecoder and its BitmapFrames. Here's the code: private static void ToXpsDocument(string imageName, string xpsName) { using (var p = Package.Open(xpsName)) { PackageStore.AddPackage(new Uri("pack://th...

Issue with WPF Focus

I have code that handles the LostFocus event of my controls. It validates the value and in some cases will enable a subsequent control. For instance, there might be a ComboBox that allows a user to select a country. The subsequent ComboBox allows the user to select a state. IF the currently selected country is not the USA, the state ...

Is there a way to get Visual Studio to unload dlls?

I have a Visual Studio 2008 project with some legacy native C++ DLL projects, and some newer WPF projects that use the DLLs. When I open the WPF xaml windows in the designer, Visual Studio loads up the native DLLs to be able to display the window. The problem is, is that if I now need to make a change in the legacy DLLs, I need to cl...

WPF doesn't honor Textbox.MinLines for Auto height calculation

I want to have a TextBox which Height grows as Iam entering lines of Text. I've set the Height property to "Auto", and so far the growing works. Now I want that the TextBox's Height should be at least 5 lines. Now I've set the MinLines property to "5" but if I start the app the TextBox's height is still one line. ...

WPF Databinding Beginner question

I'm new to the whole WPF programming, but have been doing Windows Forms programming for a while. Anyway, I have a button that when clicked will run a stored procedure on a SQL Server and display the resulting data in a grid within the same window. In windows forms world, I'd create a datatable, use a dataadapter to fill it and then ass...

Does expression blend 2 support CRUD from/to/by animation?

It seems that blend 2 only support CRUD key-frame animations via its UI. From/to/by animations must be done via editing Xaml, is my assumption correct? ...

Programmatically selecting Items/Indexes in a ListBox

In WPF, I'd like to set the selected indexes of a System.Windows.Controls.ListBox I best way I've found so far is to remove all the items from the control, insert the selected, call SelectAll(), then insert the rest, but this solution neither works in my situation nor is very efficient. So, how do you set items in a Listbox to be selec...

Is it possible to find out the assembly and file containing a DependencyObject?

Hi girls and guys! I am currently working on a little localization framework for WPF (don't even think about pointing me to locBAML...) and wondered if it was possible to find out the containing assembly of a specified DependencyObject. For example: I have a normal window definition in XAML in the file Window1.xaml. The window contains...

Click-to-edit in Silverlight

Is there a way to make a "click-to-edit" control in silverlight? I've got some items that will be displayed in a treeview control, and I would like the labels to be editable directly in the treeview. Anyone know how to do this? ...

Generate BitmapSource from UIElement

I am attempting to generate a BitmapFrame that is based on a UIElement. Here is my function: private BitmapFrame RenderToBitmap2() { RenderTargetBitmap renderBitmap = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisu...

How to detect when a hotkey (shortcut key) is pressed

How do I detect when a shortcut key such as Ctrl+O is pressed in a WPF (independently of any particular control)? I tried capturing KeyDown but the KeyEventArgs doesn't tell me whether or not Control or Alt is down. ...