wpf

In WPF, how can I bind a datagrid column to a specific column of a datatable?

I have a Datatable with many columns, and a datagrid in which I need to display only a few of those columns. I need a codesample of how to do it. I found a whole bunch of examples telling me to turn AutoGenerateColumns to true and set the table as DataContext to display all the columns in my DataTable. And I guess I could then put in a p...

WPF ObjectContext Attach Detach - Not Working

Hello, I am implementing an ObservableCollection to manage my EF entities. When i want to edit some entity, i create a clone of the entity and i open it up inside a popup window. When the user finishes to edit the cloned entity, i proceed to detach the original entity and then attach the new (cloned and edited) entity. No exception occ...

How to specify a trigger for an empty TextBox in WPF?

I have a style applied to a TextBox. The style contains two triggers - both of which check the property Validation.HasError. A different image is displayed on the background of the TextBox indicating if the data is valid or not. I'm trying to change the style so that when the TextBox is empty, no image is displayed in the background. I ...

What's the recommended way to expose standard colors in WPF

I would normally just create a static class like StandardFooColors and create a static field for each standard color. However, with WPF I could also put these in a resource dictionary. Just wondering if there is a recommended way to do this or if it is 6 of 1 or half dozen of the other? ...

Trigger when class field changed

Hi. I have created a DataGridCellTemplate where I have an Image control. By default it's Source property is X. I fill DataGrid with objects of my own class (have also implemented INotifyPropertyChanged interface). I would like to change Source property of Image control when some boolean variable changes from False to True. Should I u...

How can I set the content of a WPF button to be a Canvas in a separate xaml file generated by expression design?

I used expression design to export my vector image as a .xaml canvas. I then included this file in my project. I have a button that I want to set the content to this xaml described image. Any help would be appreciated. Should I set the .xaml canvas image thing to have its build action be resource? What's the xaml look like that conn...

DateTime Not showing with currentculture format in Datagrid,ListView

In WPF I am trying to Bind a Date property to Datagrid, and If I only have the date Property binded as DateTime format I can sort it in the datagrid. And Here I have to show the regional Date, If the user changes the Region and Language settings, The application should show the resepective time format. Here comes the Issue, When the Da...

Can anyone tell me (or send a link) step-by-step instructions of creating a vector image in expression design and importing it into Visual Studio?

Can anyone tell me (or send a link) step-by-step instructions of creating a vector image in expression design and importing it into Visual Studio and using it as the content of a control? ...

wpf datagrid - sourcecollection count is 0 newitemplaceholder is not shown

After deleteing all the items in the bound collection, the datagrid.items.count is 1 and the only item in the item collection is newitemplaceholder but the datagrid does not show the newitemplaceholder. This can only occur if the last item is the newitemplaceholder and you attempt to edit it but instead of hitting enter you click the but...

WPF Chart Series Dynamic Databinding

How do I go about binding a chart series to a datasource where the data changes? I will of course need the chart series to reflect the changes to the underlying data. I need a fresh angle. ...

In WPF how do I reference a static resource that is defined in a different XAML file?

In WPF how do I reference a static resource that is defined in a different XAML file? It's in the same project. ...

Custom WPF control with Unity failing to resolve

public class RichTextBoxExtended : RichTextBox { static RichTextBoxExtended() { //DefaultStyleKeyProperty.OverrideMetadata(typeof(RichTextBoxExtended), new FrameworkPropertyMetadata(typeof(RichTextBoxExtended))); } public byte[] Text { get { return (byte[])GetValue(TextProperty); } set { SetVa...

Efficient bitmap manipulation in WPF (C#).

Hi there, the problem is as follows: I have got a rendered bitmap in a byte array (together with the bitmap header). Now I want to manipulate the content of a bitmap. For that purpose I need to wrap this array with some high-level class, say BitmapImage . I want to avoid copying the array, or its data part etc. I want just to force .NE...

WPF ControlTemplates must have TargetType or not?

Do ControlTemplates in WPF require a TargetType? I am restyling some controls, and notice that the comboboxitem, listiviewitem and listboxitem all have the same template: <ControlTemplate x:Key="ListBoxItemCT" TargetType="{x:Type ListBoxItem}"> <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{Templa...

Strange Visual Studio Behaviour when setting Application Resource Dictionary

I'm trying to set the current WPF Application ResourceDictionary programatically. (I have a WindForms project, so no "App.xaml" to do that for me). Note: If anyone knows how to bind the equivalent of an Application.Resources to a ElementHost and all of its child controls hierarchy, this is the ultimate objective here. I added to my cod...

Is there a limit on a user setting size in .NET application?

I would like to serialize my object with many values as string(xml) into user settings. Is there a limit on how large a "string" user setting can be in a .NET application? I am extending ApplicationSettingsBase to save my settings. ...

BitmapCache causes WPF application to lock up

Here's the scenario: 1: Our WPF application starts 2: The WPF application loads various user controls, including some that use the new BitmapCache feature in WPF 4 3: Hit ctrl-alt-delete or win+l or load another application which requires UAC 4: Cancel that stuff The WPF application is now unresponsive, however it's WPF itself which...

Question about WPF Resources/Styles & Scope

i am just beginning WPF and wonder why this works <Window ...> <Window.Resources> <Style x:Name="buttonStyle"> <Style.Setters> <Setter Property="Button.FontWeight" Value="Bold" /> <Setter Property="Button.Foreground" Value="Aqua" /> </Style.Setters> </Style> ...

Binding WPF datagrid to 2 dimensional array

I have a datagrid and want to bind it to a 2 dimensional array and reflect changes in the array to ui automatically (using observable collection for example). However, I am stuck now because datagrid.itemssource = array gives me "'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding co...

Bezier curves algorithm - maybe Canonical Splines?

I've got a path that is made up of multiple points - i.e. 0,0 0,50 50,50 70,20 If I just draw this line on the screen it looks quite harsh as it puts a sharp angle at the joining of each point. Hence I was wondering what the bezier curves algorithm/method would look like which I could call that automatically change the sharp angles ...