wpf

Attached Properties in XAML without the word 'Property'

MS defines attached properties like 'Grid.RowProperty' and 'Grid.ColumnProperty', but in XAML you just call it with 'Grid.Row' and 'Grid.Column' I tried doing the same with an attached property called 'MyValProperty' that was registered with the name 'MyVal' on the class 'Foo', but the XAML won't let me type 'Foo.MyVal' and instead make...

Understanding WPF data binding scope

I have a custom control embedded within a TabItem of the TabControl. TabControl is Content of main Usercontrol as follows: <UserControl x:Class="ControlsLibrary.wpf.Alerts.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width...

Lazy loading with wpf Data Grid

Initially I am populating 100 rows in Data grid, when user scroll the grid rows, I want to populate another 100 rows. I am using wpf data grid, I have not found any event of data grid that I can catch to accomplish this task. Then I have used scroll viewer control and try to catch change event where I know that my scroll viewer reach at ...

WPF Close button not working when in Grid

Hello. When I place Button in grid and add to is's click action: this.Close(); It's not working. I want to be able to ask user before exit so I want to use Close(). I don't want to use Application.Shutdown(); How to solve it. ...

WPF Tabindexes not behaving as expected - The force is weak....

Hi All, I have a WPF window / form with various controls. I have set the tabindexes in the desired ordered but am getting strange behavior. When tabbing through the window, the order should be as follows: first text boxes on the left, then the date controls on the right, then my tab control and tab pages and then only the buttons. Bu...

Adding a ContentPresenter to the style of a Control

Hello everyone I'm trying to style an element in WPF which displays a yellow border around anything thats in it and shows a tool-tip when the cursor is over it. The problem is that I don't have much of an idea how to do this and anything I tried does not seem to work. Here is what I have until now: <Style x:Key="HistoryElementStyle" ...

CollectionViewSource CurrentChanged not triggering

I wonder if I am doing something wrong? My CurrentChanged does not seem to trigger. It only triggers on application start ListItems = new ObservableCollection<string>(); ListItems.Add("hello"); ListItems.Add("world"); ListItems.Add("foo"); ListItems.Add("bar"); ListItems.Add("baz"); viewSource = CollectionViewSource.GetDefaultView(ListI...

How to create a Dependency property on an existing control?

I have been reading on Dependency properties for a few days and understand how they retrieve the value rather than to set/get them as in CLR properties. Feel free to correct me if I am wrong. From my understanding all WPF controls like a TextBlock, Button etc that derive from DependencyObject would also contain dependency properties to ...

Textblock style toggle!

Hello... I have a style which underlines the textblock when it is mouseovered... How ever i need when it is clicked to change its font weight to bold(selected).. any idea? ...

Best way to implement margin between WPF/SL grid columns/rows

Hi all What's the best way to add margin between columns or rows in a WPF or Silverlight grid? Add fixed width/height columns/rows to the grid Add margin to the grid child controls Anything else? Thanks in advance ...

How can I list every resource files of a directory pack URI ?

Hello, I have many XML files with "Build Action" set as "Resource". I can access them from code using the well known pack URI scheme, or just a relative URI (which is actually a valid pack URI, as stated by Microsoft in the pack URI msdn page, so everything is a pack uri :p), like this : Uri uri1 = new Uri("pack://application:,,,/someF...

WPF/XAML animation using own event

Hi all, I've used WPF for quite some time now, but I've never looked serious into animation. I'm trying to achieve the following, but until now, not successful. I have a class called "Property". This class has the ability to fire an event: public class Property { // ... public event System.Windows.RoutedEventHandler Attract; ...

Accessing a classes properties for databinding with RichTextBoxes in WPF

I'm currently trying to convert a wpf form with several textboxes on it to RichTextBoxes to allow for better editing functionality. The original textboxes were all linked to an underlying storage class using databinding to a data context upon navigation to the page. public class Storage { public String IntroFormText { get; set; } pu...

How to forbid backspace key in WPF

Hi all How can I forbid the Backspace-Key as easy as possible in a WPF-Application? The KeyDown-Event don't catch at the DEL and the Backspace-Key. Thank you! ...

Display ListBox by 2 branches in WPF

I have a listbox to display a datasource. The datasource has only one field ("ClassName"). I want the listbox is displayed by 2 branches. Example: ClassName: ClassName1 ClassName2 ClassName3 ClassName4 Display: => ClassName1 ClassName2 ClassName3 ClassName4 Just tell me how to do that please! thanks! ...

C#/WPF: KeyBinding not triggering Command

I have declared <InputBindings> <UserControl.InputBindings> <KeyBinding Key="C" Modifiers="Ctrl" Command="{Binding CopyImageCommand}" /> <KeyBinding Key="V" Modifiers="Ctrl" Command="{Binding PasteImageCommand}" /> </UserControl.InputBindings> For testing purposes, I have added buttons bound to those commands too <Button Comm...

C#/WPF: Can I Store more that 1 type in Clipboard?

Can I Store more than 1 type in the Clipboard? Eg. like Text & Image. say the user pastes in a text editor, he gets the text and if he pastes in something like photoshop, he gets the image. I thought it was possible but I tried Clipboard.Clear(); Clipboard.SetText(img.DirectLink); BitmapImage bitmapImage = new BitmapImage(); bitmapIma...

WPF DataBinding specifying array index in Binding not working

I am facing a problem with DataBinding in WPF:::: The below code is working: <TextBox Text="{Binding ProcessStepBlock.ProcessStep[2].ProcessDescription}"></TextBox> <TextBox Text="{Binding ProcessStepBlock.SelectedIndex}" ></TextBox> The below code is not working:It gives me a binding error BindingExpression path error: '[ ]' prope...

How to load a grid from XAML codes and add it to a stackpanel dynamically/at runtime?

I generate the XAML codes which actually describe a valid grid control - called the GridXAML. I want to create a grid object and add it to a stackpanel on my form. How can I 1) create an object from its XAML string value, and 2) add it dynamically to a panel? Please help! Giving a specific sample context as below. The generated grid's...

wPF Requied validation using Submit button

hi how can i validate inputs against the required validation for the controls when a submit button is presed. ...