wpf

How do I add an inherited control to a datatemplate in WPF?

I need to an extra dependancy property to a control, so I'm overriding it. I.E.: namespace Custom_TextBlock_Sample { public class CustomLabel: Label { } } But I seem to be unable to add it to a DataTemplate. The following code will fail to build: ... xmlns:Custom_TextBlock_Sample="clr-namespace:Custom_TextBlock_Sample" ... ...

WPF: How to customize SelectionBoxItem in ComboBox

I want to display a custom template/item as selected item in ComboBox (this item does not actually exist in the list of items and is updated differently). This does not even needs to be an item, just providing a custom view would work. How can I do this while staying within current ComboBox theme (so no ControlTemplate replacement poss...

FindName returning null

I'm writing a simple tic tac toe game for school. The assignment is in C++, but the teacher has given me permission to use C# and WPF as a challenge. I've gotten all the game logic finished and the form mostly complete, but I've run into a wall. I'm currently using a Label to indicate who's turn it is, and I want to change it when a play...

How do you perform an animated rotate of an image in WPF?

I am just starting out using WPF. I want to rotate an image when i click a button but I don't want the image to rotate in one instant rotation. I want the use to see the image rotate one degree at a time. What is the easiest way to do this in C#? ...

Autogenerating WPF/Silverlight Views (scaffolding)

Are there any tools out there to autogenerate the different components used to make up a WPF application? Model, View, View Model, XAML form? ...

How to set value to an Usercontrol inside a ListBox Item Template while loading listbox?

Hi I have an usercontrol and inside that there is a Dependency property EmployeeSchedule which will accept a DataTable or DataRow. I created a Listbox and in the ItemTemplate i referred this usercontrol. my question is that the data for the user control is the currentrow or datacontext of the listbox item which it is placed. How will i...

WPF Drag & Drop in RightToLeft Direction

Is there a bug in WPF Drag and Drop when it runs in RTL mode? It seems it does not update the drop object area which it's FlowDirection set to RTL. I currently using WPF 3.5 + SP1 and facing this problem, Additionally, it seems this is inherited in WPF 4.0 and also does not work properly in VS2010. Who can providing a solution or workaro...

Attached Property and Binding

I'm creating an attached behavior in order to set a regular property of a class: public class LookupHelper { public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.RegisterAttached("ItemsSource", typeof(object), typeof(LookupHelper), new UIPropertyMetadata(null, OnItemsSourceChanged)); private static...

WPF equivalent to Silverlight "RootVisual"

I am trying to port an application from silverlight to wpf. Unfortunatley I am new to both. Is there an equvivalent to the following Silverlight code in WPF? private static Canvas GetCanvas() { var uc = Application.Current.RootVisual as UserControl; if (uc == null) { re...

ICommand _canExecute problem

Hi, I have the following code and it won't compile because the compiler cannot determine the return type of my CanExecute method. Can someone help me as to what is wrong? class ViewCommand : ICommand { #region ICommand Members public delegate Predicate<object> _canExecute(object param); private ICommand _E...

How to fetch all the rows in a listview wpf

Hi, I have a list view which has a grid view with four columns. The itemsSource for the listview is an IList(Of SomeType). Each cell in the grid contains a checkboxes, which are checked/unchecked based on the values in the bound property. Now i want to retrieve all the rows in list/grid view for saving purposes or atleast all those check...

Commands in WPF, Implementation question

I know I've already asked questions on this, but something that's just confusing. I'm doing a tutorial on WPF MVVM pattern, but it seems I cannot get it right, as in the tutorial, it doesn't go into detail on how to implement the ICommand interface. (not sure how correct it really is?!!) I have the following implementation of ICommand:...

C# WPF Databinding to Unkown Amount of Checkboxes

In my application I generate CheckBoxes for each possible category (retrieved from a database) and the user can check any number that apply. I name the checkboxes "cbCategory[ID]" where ID is the ID of that category in the database. I then need to generate some sort of collection class (as a property of my object class) to store the cat...

WPF treeview to be used as menu (MVVM style)

I have a requirement in which a menu should be implemented as a treeview on the left side of a window. I know how to populate the treeview with the (menu)data (the mvvm way). But: how do i hook up each object in the treeview to an ICommand (in the Viewmodel)?? so that e.g. double clicking an object results in opening a window?? Thank...

WPF Datagrid : Find Columns currently visible on screen

I want to allow the user to add a column and for that column to appear on screen. Is there a way to find which columns are currently on screen? ...

How can I access one window's control (richtextbox) from another window in wpf?

I'm sure this is something very simple but I can't figure it out. I've searched here and on msdn and have been unable to find the answer. I need to be able to set the richtextboxes selection via richtextbox.Selection.Select(TextPointer1, Textpointer2). Thanks for your help! ...

Out of memory exception.

Hi When loading a flash file of size 70MB and above in a WPF app it works successfully for one or 2 times and then it starts throwing OutofMemoryException. But when loading small flash files which are 10MB to 20 MB it always works successfully. Here are the steps that we are following: 1. ReadAllbytes of a flash file. 2. Create MemoryStr...

Ability to modify control dissapears when no properties are set

I'm adding controls programmatically to a canvas which is all just wonderful... var newControlPoint = new ControlPoint() { Width = 10, Height = 10 }; newControlPoint.SetResourceReference(Control.TemplateProperty, "ControlPoint"); SetCanvasPosition(newControlPoint, position.X - (newControlPoint.Width / 2), position.Y - (newControlPoint.H...

How to bind to a Textbox

Hi, my XAML is <TextBox Name="DutchName" HorizontalAlignment="Right" Text="{Binding customer,Path=DutchName }" /> my class is class customer { Name name; } class Name { string DutchName; string EnglishName; } The textbox is not binded. Any one correct the error plz. Thanks, ...

RelativeSource binding to a parent property of a ComboBox SelectedItem return object

Hey all, Given the data structure { Collection elements; String LocationName; } And a ComboBox that is bound to a collection of such items (described in the structure) with DisplayMemberPath set to LocationName, how do I bind a datagrid to the SelectedItem.Elements of said combo box in XAML? By my understanding the SelectedI...