wpf

Non-static dependency properties

Is there any reason why I could (or should) not declare dependency properties as non-static? I need to make an interface with two-way bindable properties. INotifyPropertyChanged seems a little bit cumbersome on the receiving end as it relies on string identifiers. ...

Can a WPF Style be used to apply currency formatting to a DataGrid cell?

I've got a WPF DataGrid and wish to apply a currency format to several of the columns. I can do this on a per-column basis using Binding={Binding FieldName, StringFormat={}{0:C}, but I'd prefer to define the currency format once - presumably in a <Style> resource - and just apply that resource to each column that needs formatting. Probl...

XAML reference control and properties in x:Array

<RichTextBox x:Name="OrigText" Margin="0,0,8,0" d:LayoutOverrides="Width"/> <Button x:Name="OrigFileBrowse" Command="{Binding BrowseCommand}" CommandParameter="{Binding ElementName=OrigText, Path=Document}" HorizontalAlignment="Center" Margin="0,0,8,2.442" Width="75" Content="Browse" Grid.Row="1" d:LayoutOverrides="Height"/> <Ric...

Is there any way to set binding for the StringFormat as well?

<TextBox Text="{Binding Path=Double, StringFormat=F3}"/> StringFormat in the below statement is hard coded. But it will change according to the culture and Customized settings. How can we se the rounding or String format using Dependency property or normal property? This can be applied to TextBox, Label , TextBlock etc where ever we wi...

Paging a Listbox control in WPF

Hello, I have a WPF ListBox with it's ItemSource property bound to an ObservableCollection. Each ListBox Item has many controls that could take some time to load up. I would like to only display/load 5 ListBox items at a time, with some paging support or a "Next" button or something similar. Currently I plan to do this manually and j...

Toggle button based on button template

Can I simplify my code? <Style x:Key="GrayButtonStyle" TargetType="ButtonBase"> <Setter Property="Margin" Value="5"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ButtonBase"> <Border x:Name="border" BorderThickness="2" CornerRadi...

WPF command - called from Window and UserControl, same handlers

How can I have a Command that can be called from both a Window and a UserControl (by hitting a button in either) that uses the same execute and can-execute methods? It seems like if I have the following in my UserControl's XAML, it requires myCommandHandler and canExecuteMyCommand to be in my UserControl class: <CommandBinding Command=...

Custom WPF ValidationRule throws Visual Studio DesignTime error

I've created a custom assembly that has some ValidationRules for regular expressions and required fields. As soon as I start using them in XAML, Visual Studio Designer throws the following error. System.Reflection.Adds.UnresolvedAssemblyException Type universe cannot resolve assembly: Validation, Version=2.0.0.0, Culture=neutral, Public...

Tab order and index in WPF usign the MVVM pattern

I'm having an issue with tabbing through the controls on a WPF application using the MVVM pattern. I have the following XAML which defines a tree structure <Grid Background="Transparent" Margin="10"> <TreeView ItemsSource="{Binding FirstLevelNavigableViewModels}" Background="Transparent" HorizontalContentAlignment="St...

WPF FlowDocument Binding

I am using Microsoft's XAML/HTML converter to convert HTML from a database into a XAML string. The Microsoft converter seems to be formatting the text correctly, but I'm having trouble binding the output to a XAML object. For example, using the following HTML: <span style="font-weight: bold; font-family: Georgia; color: rgb(0, 96, 144...

WPF - ItemsSource equivalent for Table in FlowDocument?

I'm trying to create a Table inside a FlowDocument inside a FlowDocumentPageViewer, as seen in this tutorial. I've never created a table in WPF before, and I was expecting there to be an ItemsSourceproperty to which I could bind, like with a ListBox. I want to customize the template for each row, and I want each row's source to be an i...

Changetracking and concurrency - can this fail?

I've been messing around with Expressions - and I may have gone beyond my capabilities - but here goes... I've implemented 'type-safe' INotifyPropertyChanged implementation (an example is here), but gone a bit farther and included changetracking: public abstract BaseViewModel<TEntity>:INotifyPropertyChanged { private readonly IBaseC...

Using ActiveX control in WPF

I'm attempting to host an ActiveX control in a WPF app. After attempting to use existing info on the web and here, I've hit a dead-end. I need to use an ActiveX control provided to communicate with a UV power meter. They provide an application that registers and uses the control and even includes some useful demo apps. I stripped out th...

Set the Default Date of WPF Date Picker to Current Date

Hi, I have a WPF Datagrid in which one of the columns is a Date Column. So i have used a DataTemplateColumn as Follows <my:DataGridTemplateColumn CellTemplate="{StaticResource EffDateDateTimePickerControl}" CellEditingTemplate="{StaticResource addrEffDate}" Header="Effective Date"/> And in my Resource File i have written...

how to get the double-click-time in WPF

How I can get the duration in milliseconds that is valid for a DoubleClick in WPF. The same as in Windows Forms the SystemInformation.DoubleClickTime-property was. ...

How to use the Insert Key (like in traditional windows) for a WPF 4 App?

Ok, I know that the new versions of windows do not use the insert key by default and you have to program for it. I want to be able to type in my text box and override the content that is in it just like in old windows when you could activate the insert key. This is just for my WPF 4, VB.net Application. Updated Information: That what I...

Why doesn't this SetBinding ImageSourceProperty Work?

let mtvCapView = Rendering.MTViewerCaptureViewProvider(subRead) let image = Image() let imageBinding = Data.Binding("ImageElement") imageBinding.Source <- mtvCapView image.SetBinding(Image.SourceProperty, imageBinding) .... Grid.SetColumn(image, 1) grid.Children.Add(image) The MTViewerCaptureViewProvider class exposes an property ...

The current co-ordinates of a given WPF Control

Given a System.Windows.Controls.Control, how can I find the top left and bottom right corners of the control, in pixels? Also, how can I then set the said corners? I want to be resizing or moving the control arbitrarily based on where it currently is. I'm in C#. Thanks. ...

Still Confused About How To Detect FlowDocument Change and Scroll

I read through the following article: http://stackoverflow.com/questions/1655208/detect-flowdocument-change-and-scroll I have a FlowDocumentReader, not a FlowDocumentScrollViewer, with its ViewingMode set to Scroll. I still cannot figure out how to automatically scroll my FlowDocumentReader to the bottom when content is added to my Flo...

WPF tab-control with the same controls for all tabs

How do I create n-numbers of tabs with the data controls in wpf? Let's say the main application has a button called "new customer" and "save data." When "new customer" is pressed a new tab appears with two text boxes "Name" and "Customer Number" contained in the tab, and so on. Once the two fields are populated, pressing the "save Data"...