wpf

How to create an Attached Behavior for automatic scrolling of a FlowDocumentScrollViewer

My goal is to create a reusable Attached Behavior for a FlowDocumentScrollViewer, so that the viewer automaticly scrolls to the end whenever the FlowDocument has been updated (appended). Problems so far: OnEnabledChanged gets called before the visual tree is completed, and thus doesn't find the ScrollViewer I don't know how to attac...

Resizing the WritableBitmap

Hello All, I have created a WriteableBitmap in Gray16 format. I want to resize this WriteableBitmap to my known dimention preserving the pixel format(Gray16). Is any one worked on the Resizing the WriteableBitmap. Please help me. I also searched the internet and found http://writeablebitmapex.codeplex.com/ but this through an assebml...

Set Accessor in WPF

Is this a true statement? the Set accessor never gets called unless someone sets the .Net property in procedural code. When setting the property in XAML, data binding to it, and so on, WPF calls SetValue directly (or may be is an old statement) Thanks ...

WPF ContextMenu and CanExecute timing

So I have a context menu in a TreeView and it wasn't enabling the MenuItem because CommandParameter was always null. What I discovered is that CanExecute gets called before PlacementTarget is set and therefore before CommandParamater changes. So in TargetUpdated I force the command to fire CanExecuteChanged. <ContextMenu> <MenuItem...

When has CanFreeze to be used?

Is it necessary to always check CanFreeze before freezing an object. If I look at PresentationOptions:Freeze to use in markup, there is it not done. Therefore I dont think, that CanFreeze must be called before everey object-creation. But when has CanFreeze to be used? ...

How to Refresh a ListItem in WPF ListView ,CollectionViewSource in MVVM

I have an ObservableCollection assigned to People and have a PersonViewModel and a PeopleViewModel _people= GetAll().ToList(); List<Person> allPeople = (from person in _people select new PersonViewModel(person)).ToList(); AllPeople = new ObservableCollection<WorkOrderListItemViewModel>(allOrders); AllPeopleCo...

WPF DataBinding: Nullable Int still gets a validation error?

I have a textbox databound to a nullable int through code. If I erase the data from the textbox it gives me a validation error (red border around it). Here is my binding code: ZipBinding = new Binding("Zip"); ZipBinding.Source = Address; zipTextBox.SetBinding(TextBox.TextProperty, ZipBinding); public Int32? Zip { get { ... } set { ......

Make my own Installer from C#?

Hi everyone, I've been quite liking the new Installer's Microsoft have used, mainly for their Blend installations which use WPF, I'm wondering if I can make something like this for my application? The main worries are creating the Program Files Directory and registering the application with Windows so it adds it to the add/remove appli...

How to create DataTemplate with Links

Hi, I'm trying to create DataTemplates for a PropertyCollection (of PropertyDescriptors) to display the items in the collection in this format, descriptor1 > descriptor2 > descriptor3 > descriptor4 > descriptor5 Each descriptor would be a link (using Hyperlink), my question is can I do this with Labels (which is not an ItemsControl ho...

I am trying to draw a 3d cube, but it does not work. Code inside.

EDIT: Fixed Hello everybody, I have got the following eventhandler in my Window: private void buttonView_Click(object sender, RoutedEventArgs e) { //Camera PerspectiveCamera camera = new PerspectiveCamera(); camera.LookDirection = new Vector3D(5, -2, -3); camera.Position = new Point3D(-5, 2, 3); camera.UpDirection =...

WPF xmlns for an aliased assembly?

I'm trying to access System.Windows.VisualStateManager by bringing in a DLL from the Silverlight platform into WPF. It's System.Windows.dll and it conflicts with another dll (WindowsBase.dll I believe) so I gave the assembly an alias to sort out complications there. In my code behind I can access all the classes/enums/what-not that I nee...

WPF: What is between the Initialized and Loaded event?

I want to run some code when the Window or Control is first displayed. I can't use Loaded because that can fire more than once. I can't use Initialized because that is done by the constructor. Is there an event somewhere between? ...

Silverlight/WPF: I Don't Want ICommand to Change Button's IsEnabled Property, Is this possible?

So say I have a button (MyButton) that binds to: public ICommand MyCommand { get; set; } I register this command with: MyCommand = new DelegateCommand<object>(DoSomething); Now if I do MyButton.IsEnabled = false; It doesn't do anything, i.e., the button is still enabled. I know that the command is causing this to happen because ...

What is the best way to replace controls at runtime?

I'm fairly new to WPF and I have this scenario: I have an application that contains an area where different sets of controls should be displayed at different time(different application states). I'm wondering what is the approach in WPF? In winforms I would make controls visible/invisible at runtime. If there were too many controls I w...

Databound ContextMenu Separator not honoring global Separator Style

I have a context menu bound to a data source. For this context menu I have a DataTrigger to display a separator if the databound object has a value of "True" for the Separator property. This works well however it doesn't seem to pick up my global style for separators that I have in my application. The new separator appearance is differen...

Validation Error wpf with IDataErrorInfo and DataNotations

Hi all, I got i issue where the validation appear right but the canexecute don't run again. What i mean is if you put a string in the int field the validation don't go to viewmodel again and the button still be enabled and should be disabled. Someone have a solution for that? view <TextBlock Grid.Row="2">Age</TextBlock> <TextB...

Unable to use "BasedOn" on WPF Resource that has MergedDictionaries

Hi, In an WPF app, I am trying to use the Aero theme in XP. I currently have this: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/PresentationFr...

How to make filtered ListView to reflect changes of item field which is used in filter criteria?

I am trying to make a ListView filtered, and I found it easy to achieve it. Both of those 2 methods do it perfectly: private void ToggleHiddenReleases(bool show) { ListCollectionView view; view = (ListCollectionView)CollectionViewSource.GetDefaultView(ListBoxAll.ItemsSource); if (!show) view.Filter = (mr => !((ModelRelease)m...

How do I make WPF case-insensitive?

I dislike WPF's inability to interpret text in a case-insensitive way. Are there any tools (i.e. VS plugins) out there that will take my VB .NET code and handle the case-sensitivity issues for me? Edit: Now with examples. Input: <Dockpanel DockPanel.Dock="Bottom"> <Label Content="(c) blahblah" HorizontalAlignment="Left" Name...

How to animate the font weight of a label in WPF?

I'm having trouble finding an animation storyboard type that allows me to animate the FontWeight property of a label from "Normal" to "Bold". Does anyone have any experience with this? ...