wpf

C# Clear a BitmapImage or the instance of it.

I would like to clear a bitmap image. I've tried both uploadImage.Source = null; and uploadImage.Source = ""; This is the code I used to make the image: // BitmapImage.UriSource must be in a BeginInit/EndInit block BitmapImage myBitmapImage = new BitmapImage(); string curItem = destinationFolder + "\\" + listBox1.SelectedItem.ToS...

WPF Button isPressed and isEnabled problem...

Update: using Expression Blend 3 I'm trying to style the IsPressed & IsEnabled(false) property triggers for a class of buttons in a WPF application. Here's a UserControl with a Button using the style... <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/20...

TargetTypes for Custom Control Templates?

I am extending the WPF Calendar control, and I have copied the control templates for the Calendar, CalendarItem, CalendarButton, and CalendarDayButton to the Generic.xaml of my custom control. The TargetType for the Calendar control template is my custom control, FsCalendar: <!-- Calendar Control Template --> <Style TargetType="{x:Type ...

How do I expose custom control properties inside a user control?

I have a custom control called TextBoxWithLabelAndUnits. From the name, you can tell that it's a TextBox that has a Label before it and a Label after it, so that the custom control looks like this: ----------------- Label: | | units ----------------- I expose several dependency properties to configure the c...

What's the best way of access a random number of controls in WPF DataTemplate

I'm building a questionnaire application that shows a series of questions to the user. To simplify the model, the question is represented by class Question{ String name; bool ComboBox; String[] choices; } In the code-behind I have a ObservableCollection that is used by the DataContext. The XAML looks like this ... <Item...

Visual Studio 2010 and WPF: Creating a special template

Hi! :-) Is it possible to do the following in VS 2010: Create a new template (or something similar) so I get a XAML - view and a view model, completely with the INotifyPropertyChanged implementation and a view model invoker, all in one? Create a project template that gives me a view and a full view model in App.OnStartup(...) instead ...

WPF: DataContext dependency property in non - GUI - classes?

Is it possible to have a dependency property "DataContext" in a class that is NOT derived from "FrameworkElement" (but it can be derived from "DependencyObject")? I already tried and created a class (which I added to Window.Resources), but the DataContext is always null. Any ideas? ...

Report data is not displayed - WPF

Hi, I have just started to make report in wpf, but getting following error An error occurred during local report processing. The report definition for report 'Project Path' has not been specified. Could not nto fild file 'File Path' here is my code private void Window_Loaded(object sender, RoutedEventArgs e) { List<Model....

How to catch/handle the window form's hidden/showed events?

In my application I call App.Current.MainWindow.Show()/App.Current.MainWindow.Hide() to show/hide my application but I don't know how to catch the event when the form is hidden/showed. Please help if you know how to! ...

Stop Datagrid selecting first row by default

I am using Wpf Toolkit DataGrid. Whenever I assign Itemssource to it, its first item get selected and its selectionChanged event gets called. How can I stop it to select any row by default? ...

How to add DataTemplate into resources?

I have a class Wizard which creates a wizard with pages defined in the same project. The PageViewModel is separated from PageView. PageViewModel is an ordinary C# class derived from PageViewModelBase abstract class and PageView is a UserControl. In order to define a mapping between PageViewModel and PageView I wrote the following code fo...

Brushed steel brush in WPF?

I am looking for ideas to create a WPF Brush with a brushed steel look, similar to the MacOSX Panther style, preferably without resorting to an ImageBrush. Is there a funky way to use a GradientBrush to create this effect? Thanks in advance! ...

How to raise an attached event in wpf?

How can I raise DataObject.Pasting event from my code? ...

Binding a control to a data class using WPF/XAML

Hello, I am trying to bind a data class to a ListView control in WPF, but can't seem to get it working. I can bind it at run-time and get it working using the following: this.DataContext = DataSet; But, if I try the following in the WPF/XAML is doesn't work which looks like: DataContext="DiscoveredItemContainer" I have tried vari...

Binding to Children.Count

Hi, I'm using a binding of the form {Binding RelativeSource={RelativeSource Self}, Path=Children.Count, Converter={StaticResource CountToDimensionConverter}, ConverterParameter=Rows} Despite adding the children in xaml, when I break in the converter, the value is always 0. What I assume is going on is that the children are not adde...

Is it possible to update a DoubleAnimation.FromProperty without restarting the entire animation?

I'm not hugely familiar with a lot of WPF yet, so if this query betrays some clear misunderstandings I'd appreciate them being pointed out. What I'm trying to do (for good or ill) is synchronise a DoubleAnimation.FromProperty with the actual width of a StackPanel containing/running the animation. I originally tried doing this with data...

How to implement a progress bar using the MVVM pattern

I have a WPF application which is built on the MVVM design pattern. I wish to implement a progress bar in the app, that follows the MVVM pattern. Does any one have any suggestions on how to implement this? Thanks in advance ...

WPF ICollectionView Filter Reset

Hi! I have a CollectionView from an ObservableCollection: private static ObservableCollection<CalculationViewModel> _calculations; CalculationViewModelsCollection = (CollectionView)CollectionViewSource.GetDefaultView(_calculations); My problem is that, when the result of the filter is nothing, I'd like to clear the filter, and refil...

How can I to detect if an Application been created with Winforms or WPF ?

Without entering the code? ...

WPF - Programmatically raise a command

I have a button: <Button x:Name="MyButton" Command="SomeCommand"/> Is there a way to execute the command from source? Calling the click on the button does not help: MyButton.RaiseEvent(new RoutedEventArgs(Button.ClickEvent)); I mean - this does raise the event, but it does not raise the command. Is there something similar to this R...