wpf

DataGridCell.IsEditMode?

How Can I know if the DataGridCell is currently in edit mode (not IsSelected), I mean, for example a DataGridTextColumn cell is clicked it becomes a TextBox and not a TextBlock, that's what I call IsEditMode. I wanna set a trigger-setter for this mode. EDIT: I tried to set a general style for DataGridCell.IsEditing but it doesn't seem t...

WPF - automatically relocating children when parent resizes

I have a container whose size can change. I will by dynamically creating instances of a user control and adding them to that container. the size of the user control is fixed. what I want to do is, fit the most number of user controls in the container. I think a good approach is to add the children horizontally until there is no more sp...

Chessboard in WPF

For years I've developed with Winforms, now I want to switch to WPF and make a chessboard. Unfortunately I have no idea where to start. Using WPF makes me very unsure, I'm feeling like a noob again. Can someone outline a basic design? I guess I would start with a 8x8 Grid and use rectangles for the squares, images for pieces. And then? A...

Content of a WPF button - unable to put anything but text

I designed a nice STOP graphic with red bg and gradient and all that in Expression Design - just like it'll look on a real taperecorder or something. I exported it as a XAML WPF Resource dictionary and got the XAML code. I want this graphic to appear inside the button along with the text "STOP". If I directly paste the XAML inside the...

WPF transform confusion

I Have a canvas full of objects that I zoom and pan using this.source = VisualTreeHelper.GetChild(this, 0) as FrameworkElement; this.zoomTransform = new ScaleTransform(); this.transformGroup = new TransformGroup(); this.transformGroup.Children.Add(this.zoomTransform); this.transformGroup.Children....

WinForms - Enable DesignMode

For a OSS project, I'm trying to add controls programmatically to a WinForms view.. and I want to make these editable and resizeable as in the Visual Studio Designer. I've been playing around with adding programmatically, using Controls.Add(label).. but I'm struggling to work out how to make the UI editable. I'm assuming it would make u...

TabControl.VerticalAlignment = Stretch doesn't do anything.

Hell, I am trying to make a TabControl to auto resize according to the its outer space(it's in a StackPanel): <Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="100"> <Grid> <StackPanel> <TabControl ...

Entity binding to select table columns

I am just learning to use the Entity framework and I wondered how I can bind to a select few columns with my WPF Toolkit datagrid? Can someone give me an example? I've tried to set the DataContext to the Person Entity for example and then set the Itemsource binding path to a single column of the table, but it does not work. ...

WPF Datagrid doesn't show resultset

I have a list which contains the data that is shown in my WPF Datagrid. I have the following code which searches the grid for a match with a textbox entered string. the code is in a button click handler. var search = from s in dglist // dglist is my List<APerson> where s.FirstName == textBox1.Text ...

PropertyChanged affecting several properties

I have a situation where I have a couple of variables who's values depend on each other like this: A is a function of B and C B is a function of A and C C is a function of A and B Either value can change on the UI. I'm doing the calculation and change notification like this: private string _valA; private string _valB; private string _...

How to make ScrollViewer automatic

I tried to place a TextBlock inside a ScrollViewer, and the scroll bar shows up correctly, but I cannot seem to make it automatically scroll down when the Text property of the TextBlock is updated. Here's the relevant part of the XAML: <ScrollViewer> <TextBlock FontFamily="Consolas" Text="{Binding Current.Current.Discussion}" ...

Is there a way to define XAML elements as non-printable?

I have chunks of XAML displayed on my screen that I make printable with a print button inside that chunk, something like this: <Border DockPanel.Dock="Top" x:Name="PrintableArea"> <StackPanel HorizontalAlignment="Right" VerticalAlignment="Bottom"> <ContentControl Background="Green" x:Name="ManageButt...

Is there an easy/built-in way to get an exact copy (clone) of a XAML element?

I need to make areas of XAML printable and so have make this button handler: private void Button_Click_Print(object sender, RoutedEventArgs e) { Customer.PrintReport(PrintableArea); } And in PrintReport I pack the frameworkelement into other elements in order to print it in a slightly different way than it is on the screen, like t...

WPF: Format Value in XAML with Decimal Seperator?

I have a little problem formatting double values in my XAML code. double price = 10300.455; This number should be displayed as 10,300.45 on US systems and as 10.300,45 on german systems. So far I managed to limit the numbers with the following Binding="{Binding price, StringFormat=F2}" But the result is 10300.45 and that is not wh...

Databinding and Triggers compatability in WPF

Hi all, I have a problem. I made a template for a TreeView and I need to set the initial value of the ToggleButton's IsChecked property depending on my model. But it turns out that setting this property using triggers/setters disables the databinding. Is it so? If yes, give me a suggestion how it can be fixed? <DataTemplate x:Key="Cel...

How I could assign a preset set of string values to a field of table in SQL Server 2008?

I want a field in a table of SQL Server 2008 to contain a preset number of string values for user to be able then to select one value from a dropdown listbox in my WPF front-end app. Is it possible only through assigning a numeric int type in a SQL Server table field and then doing all the stuff through C# front-end coding, or are there...

Global KeyHook in WPF application

I need my WPF application to gain focus whenever the user press "window key + s". My solution was to hook to the keyboard event with SetWindowsHookEx. however the handle I get in return is always 0. when I call to GetLastWin32Error the value is also 0 (i.e. so it actually reports that the previous operation succeeded) _hookHandle = Set...

Wpf Login System

Hi everyone. i am developing a training software in wpf. but i have problems. this application will be setup project. when the user make it work, a login window will open. User should enter his username.there wont be a password. but the problem is next; i dont know how to get userid from database. and compare other usernames to get t...

WPF - Change a style in code behind

I have a list box that displays the results of a TFS Query. I want to change the style of the ListBoxItem in the code behind to have the columns that are included in the query results. The style for the ListBoxItem is defined in my Windows.Resoruces Section. I have tried this: public T GetQueryResultsElement<T>(string name) where T :...

How to view/edit RTF subscripts in WPF RichTextBox

Hi, I've got the following RTF fragment as data to display in a WPF rich text box. C\dn4\fs14 6\up0\fs18 H\dn4\fs14 12\up4 +2\up0\fs18\par It looks like the \dn4, \up0 and \up4 tags are ignored by the WPF rich text box, which displays this fragment with varying sizes (fs14 and fs18), but with a common baseline for all of the text. Is...