wpf

WPF RichTextBox does not delete text

Hello. Hi! I am trying to cancel (prevent) some text editing in RichTextBox. I am using TextChanged event, but I did not find the way how to cancel or rollback some changes, any ideas? private void mainRTB_TextChanged(object sender, TextChangedEventArgs e) { TextRange text = new TextRange(mainRTB.Document.ContentSta...

WPF 2 ComboBox binding problem

I have the following problem: there is a class with a couple of string properties there is a collection of such class entities That collection is shown in tree on the left of some windows and details shown on the right. I'm binding string properties of selected node to comboboxes in details. First combobox always have the same Ite...

What's the best way to go about form validation in WPF (with databinding)?

I have several forms with many textboxes/comboboxes, and I would like to have the "Save" button disabled while at least one of the fields are invalid. I've been able to setup some custom ValidationRules, like so (textbox example shown): <Binding Path="Name"> <Binding.ValidationRules> <my:TextFieldNotEmpty/> </Binding.Val...

How can I bind certain properties belonging to a custom control?

If I have the following control: public partial class MyControl : UserControl{ public string MyControlText{ get { return MyTextBox.Text; } set { MyTextBox.Text = value; } } public MyControl(){ ... } } How can I bind to the "MyControlText" property when I place the control on one of my pages, like so: <lo...

WPF: How do I set the Owner Window of a Dialog shown by a UserControl?

I've got a WPF application with these three types of things... WindowMain UserControlZack WindowModal UserControlZack1 sits on my WindowMain... <Window x:Class="WindowMain" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr...

WPF toolkit datagrid

Hi all, I want to show datagrid content (rows,columns) in XPS document.I have 20 columns. When i sent datagrid to XPS with XPSDocumentWriter.Write method ,it just show some columns not all of them.How can i show all columns and rows in xps(like Xceed datagrid xps exporting) Thx ...

What is the difference between Width and ActualWidth in WPF?

I am currently working with Panels in WPF, and I noticed that as regards the Width and Height properties, there are also two other properties called ActualWidth and ActualHeight. ActualWidth Gets the rendered width of this element. This is a dependency property. (Inherited from FrameworkElement.) Width Gets or se...

Acessing WPF XAML Resources from non-WPF code

I am currently building an application that consists of several components, each of which is essentially a WPF user control with a little C# code around it for the plugin system to work (using MEF). The problem I am having is that each component should include an icon and for niceness purposes I defined that as a System.Windows.Media.Br...

Markup Extensions in WPF/Silverlight

Has anyone ever created a custom markup extension in WPF or Silverlight? When would you ever want or need to do this? Any tips or sources on how to do it? ...

How to Import System.ServiceProcess namespace into WPF project? Not showing in CodeSense

Guys, how can I import the System.ServiceProcess namespace into a WPF project in VB.net (not C#)? The ServiceController object is not in the toolbox in VS2008 and can't see to figure it out. Any ideas? If that particular namespace cannot be imported into WPF projects, could somebody suggest another way of controlling windows services fro...

WPF - C# + Cannot get MediaElement Storyboard to autoreverse

Hi, this is driving me pretty crazy. I'm trying to get a WMV file to autoreverse after it's done playing, but it doesn't work. I've tried setting Storyboard autoreverse to true, but this throws an error saying that "Clocks with CanSlip cannot have parents or ancestors with AutoReverse, AccelerationRatio, or DecelerationRatio." Is this...

Binding TextBlock Linq ToSql & WPF.

Hi, i have a LoginWindow with username and password to access in the software after that the user authenticated i want show in the next window(the mainWindow of the software) the name of the user authenticated in a TextBlock ...i show a code snippet of my LoginWindow: public partial class Window1 : Window { public Window1...

How to add more that one resource to a XAML window?

I have a little problem right now and I don't know how to fix it. I want to add two resources to a window. One is a XAML File style resource, the other a ValueConverter Class. Both of them work if I use only one resource at a time: <Window.Resources> <ResourceDictionary Source="Resources\MyStyles.xaml" /> <Window.Resources> or ...

WPF FrameworkElement

I am new to WPF programming model. I have few queries: Does Page tag in XAML (in an XBAP application) is of type FrameworkElement? if i have a child element lets say Frame inside a Page. I pass that frame element in a function in another assembly. Now i try to navigate back to the Page from Frame control's Parent property i am not able...

How do I create a WPF dialog on runtime?

My current project creates UI by WPF at runtime. Everything works well. The only issue about it is that the global WPF template is ignored for some reason. We created a skin that is attached to the main form and thus used by all xaml created UI elements. My own code just dynamically creates items like this: var textBox = new TextBox()...

WPF ListBox - Getting UIElement instead of of SelectedItem

hi there, i created a ListBox that has a DataTemplate as Itemtemplate. however, is there an easy way to access the generated UIElement instead of SelectedItem in codebehind? when i access SelectedItem i just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from th...

Select Nullable type in Combo

My problem is simple. I want to select a nullable Type inside a combo box which is previously binded. Please help me. PS: Please do not supply any workaround, related to Modify my data, inserting a nullable inheritor or whatever related. It's there any straight forward way to achieve this??? I know they might be much people who had ...

How to create a WPF Window without a border that can be resized via a grip only?

If you set ResizeMode="CanResizeWithGrip" on a WPF Window then a resize grip is shown in the lower right corner, as below: If you set WindowStyle="None" as well the title bar disappears but the grey bevelled edge remains until you set ResizeMode="NoResize". Unfortunately, with this combination of properties set, the resize grip also ...

WPF - canvas height in pixels

How can I determine the width in pixels for a canvas (which has a certain width)? I have a bitmap in an AnimatedImage control, and I know the bitmap's width in pixels, and I want to scale the bitmap so that it horizontally fits exactly the canvas. How can i determine this scale? Note: I do not need to use RenderTargetBitmap, because t...

Realtime 1394 firewire video in a WPF app via directx or other method

Are there any controls that anyone is aware of that I can use to stream firewire video into a WPF app. I do not need camera control or capture just the video. I need WPF hosting because I'll be adding WPF content on top. I was hoping that with the addition of having direct X surfaces in WPF something like this might appear. Ideally l...