wpf

Two-pass UI Layout : Why?

I've noticed that Android, WPF, and Silverlight all follow a two-pass layout pattern. There's a recursive Measure() method that gets called to size the element, possibly multiple times. Then a recursive Layout/Arrange() method is called which lays out the exact positions of children in their parent control, and will also set the final si...

Setting a custom property within a WPF/Silverlight page

This sounds like it should be simple. I have a Page declared in XAML in the normal way (i.e. with "Add new item...") and it has a custom property. I'd like to set that property in the XAML associated with the page. Trying to do this the same way that I'd set any other property doesn't work, for reasons I understand but don't know how to...

combo box inside a user control disappears when style is applied in wpf

Hi, I am trying to apply a style to a combo box but instead of getting applied the combo box itself disappears. Please check the following xaml code for user control. <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows...

Adding WPF window to Win32 application

I have a monster of a win32 application with GUI based on a mixture of MFC, WTL, user32 and a few other technologies. I need to add another top-level window and I would like to give WPF a chance. Could you help me identify the steps necessary to host a WPF window in win32 app? Details are welcome. ...

How to set the default value of DateTime to empty string?

I have a property called Raised_Time, this property shows the time at which alarm is raised in datagrid Cell. I don't want to show anything in the datagrid cell when user creates any alarm, it just display the empty cell. I googled in the internet and found that the default value of DateTime can be set using DateTime.MinValue and this w...

How to format specific text in WPF?

Hi, I have this code that adds dotted lines under text in text box: // Create an underline text decoration. Default is underline. TextDecoration myUnderline = new TextDecoration(); // Create a linear gradient pen for the text decoration. Pen myPen = new Pen(); myPen.Brush = new LinearGradientBrush(Colors.White, Colors.Wh...

Session Per Presenter NHibernate Desktop App - Not loading latest data from database

I'm writing a WPF NHibernate Desktop App using Session Per Presenter. I have a list view showing all the saved SalesOrders and an Edit Sales Order form when you double click on a Sales Order. Each of these forms has a Session Object which lasts for the lifetime of the form. When a SalesOrder is saved it publishes an Event which tells th...

Navigation controls for a WPF Frame/WebBrowser with POST data

Hi, I need to display a web page inside a UserControl. To navigate to the web page I need to provide POST data. So far, so good. But I also need is to have some navigation controls (back/forward) to function according to the user's navigation inside the web page (just like a normal browser would act). What I tried so far is to put a Web...

WPF: Saving a TransformedBitmap Object to disk.

Working in WPF and C#, I have a TransformedBitmap object that I either 1) Need to save to disk as a bitmap type of file (ideally, I'll allow users to choose whether it's saved as a BMP, JPG, TIF, etc, though, I'm not to that stage yet...), or 2) Need to convert to a BitmapImage object as I know how to get a byte[] from a BitmapImage obje...

WPF: Textbox scrollbar has no thumb.

My textbox is the only control on a window, which is a part of a bigger application. The textbox contains a certain amount of text, large enough to show vertical scrollbar. The scrollbar appears, but without a thumb: I can still scroll the contents, either with mouse wheel or by clicking the arrow-buttons repeatedly. When I create a...

WPF TabControl / File open needs to locate child WindowsFormsHost

I'm trying to write a text editor in WPF and I have a problem trying to locate the correct instance of an editor within a TabControl in response to a File -> Open action. Tab items are added programatically and contain a WindowsFormsHost instance which in turn allows each tab to display an editor provided by the ScintillaNet WinForms co...

[WPF] Synchronously download an image from URL

Hi, I am trying to do a simple thing but I can't ... I just want to get a BitmapImage from a internet URL, but my function doesn't seem to work properly, it only return me a small part of the image. I know WebResponse are working async and that's certainly why I have this problem, but how can I do it synchronously ? Here is my functi...

Make XamlReader.Load ignore unknown xml instead of crashing?

How do I make XamlReader.Load to just ignore unknown attributes and elements instead of throwing exceptions? It would be much more useful if it only ignored those. ...

Has a Cloth Simulation ever been done in WPF or Silverlight?

I'm trying to find out if any sample Cloth simulation exists with code in WPF or Silverlight. So far this is what I've found: It's been done in DirectX and then used as an ImageBrush in WPF, but I mean without a DirectX and without a C++ dependency. It's been done in Flash and even Javascript so it's definitely possible performance wi...

Rounding a Value in the WPF Binding

I'm attempting to implement a progress bar with a textbox on top that also displays the progress %. However the percentage is fractional. Is it possible to round a value returned in the dataset via the binding or does it have to be done via the code behind? <ProgressBar Grid.Row="2" Grid.ColumnSpan="2" Height="25" HorizontalAlignment=...

XPF.Grid.GridControl access row data

Hello. I use XPF.Grid.GridControl, bind to IEnumerable data gridControl.DataSource = dataSource; I need highlight row depend on cell value. Cell contains color name. Ok I use: <dxg:GridControl.Resources> <Style x:Key="ColorRowStyle" TargetType="{x:Type dxg:GridRowContent}"> <Setter Property=...

In C# WPF, why is my TabControl's SelectionChanged event firing too often?

I have a tabbed GUI with each tab containing a Frame. In one of these Frames there is a DataGrid. When the user selects this tab, I need my datagrid sorted, so I'm using the TabControl SelectionChanged event to trigger the sort. However, this event triggers every time an item is selected from the DataGrid, even though the tabs themselves...

DataGridComboBoxColumn ItemSource Binding Doesn't work

In all of the examples of DataGridComboBoxColumn ItemSource comming from the Resources. Couldn't it be binding directly to a list in the CodeBehind ? ...

How to set a usb camera as a source to wpf MediaElemt in VS2010 in c#?

Hi, I have a Windows WPF application and I want to stream a video from my usb camera using MediaElement control. Is it possible to set usb camera as source to MediaElement? I'm using VS2010 framework 4.0 and c# language. ...

C# WPF Linq to SQL Databinding

Hi, i have generated a Linq to Sql class which looks like this. so i have 3 querys which gets my data. private IQueryable<Gesellschaft> loadedGesellschaft; private IQueryable<Anschrift> loadedGesellschaftAnschrift; private IQueryable<Email> loadedGesellschaftEmail; private lgDataContext completeGesellschaft; private void Button_Cl...