wpf

Changing Position of an Element Programmatically in WPF

I did not knew that this simple thing would be slightly complicated. I have a Canvas in which I am trying to add Ellipse dynamically. Here is the code: <StackPanel> <Canvas Name="canvas" Background="LightBlue" Margin="5" Width="250" Height="250"> </Canvas> <Button Content="Draw Images" Click="Button_Click" Wi...

Listview Binding

xaml code <ListView Name="lvw" VirtualizingStackPanel.IsVirtualizing="True" ItemsSource="{Binding Source={StaticResource MyList}}" > <ListView.View> <GridView AllowsColumnReorder="true" VirtualizingStackPanel.IsVirtualizing="True" > <GridViewColumn x:Name="MiaCode" DisplayMemberBinding="{...

WPF: resize parent container when child's ControlTemplate changes

I have a custom error template for my TextBox. Something like this: <Style TargetType="{x:Type TextBox}" x:Key="ErrorTemplateStyle"> <Setter Property="Validation.ErrorTemplate"> <Setter.Value> <ControlTemplate> <StackPanel Orientation="Vertical"> <Border BorderBrush="Orange" Bo...

WPF Databinding - ListBox doesn't refresh after property changed

Hi, i'm new in WPF so it's possible, that i make some mistakes. I'm trying to bind two ListBoxes <ListBox Margin="8,12.07,0,8" SelectionChanged="lbApplications_SelectionChanged" Grid.Row="1" x:Name="lbApplications" Width="267.914" HorizontalAlignment="Left" ItemsSource="{Binding Path=Applications, Upd...

WPF TextBox ugly borders problem

Hi! I want to override the default TextBox borders in WPF. I have this style that applies on all TextBoxes. <!-- StyleTextBox--> <Style x:Key="StyleTextBox" TargetType="{x:Type TextBox}"> <Setter Property="MinHeight" Value="20" /> <Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="Margin" Value="3"/> ...

WPF - Unable to clear items from a databound itemscontrol

Hi, I've created a combobox and have bound it to an observableCollection. Something like myCmbBox.ItemsSource = myObsCollObj My scenario is onLoad of the application I shall populate my observableCollection with some values. Now, my UI also gets refreshed with those values automatically. If the user selects a different value from ano...

Is there a way to watch WPF Routed Events?

I was wondering if there's a way to watch all RoutedEvents that are raised in a WPF application. A way to write some info about the events fired to the console would be prefect to see what's going on. ...

WPF Deployment problem: Dozens of message boxes on cient's laptop

I've written a hefty LOB application, which runs perfectly on XP SP2, Vista SP1 and Server 2003, and has been tested on 6 different machines so far. My client has an HP laptop running Vista SP1 with .NET Framework 3.5 SP1, yet for some reason when the application is run on his laptop, on some screens simply moving the mouse pointer cau...

WPF Textbox binding and line breaks

I have a textbox that i am binding to the viewmodel's string property. The string property is updated within the viewmodel and it displays the text within the textbox through binding. The issue is that i want to insert the line break after a certain number of characters in the string property and i want that the line break is shown over...

Hidden features of WPF and XAML?

Here is a large number of hidden features discussed for variety of languages. Now I am curious about some hidden features of XAML and WPF? One I have found is the header click event of a ListView <ListView x:Name='lv' Height="150" GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"> The GridViewColumnHeader...

Any way to declare routing strategy for an WPF element?

Suppose we have a WPF element, for instance StackPanel with Buttons, Textboxes etc. inside. Is there any way to say directly in XAML that I want a tunneling strategy? <StackPanel RoutinStrategy="Tunneling" ... ...

How do you show formating charachters in a FlowDocumentPageViewer?

I am building a tool to display diffs between two text documents and I need to show formatting. Anyone know how to do it in a FlowDocumentPageViewer or WPF? ...

How to change the look of an inactive window in XAML?

When I change the style of my window to WindowStyle="None" and AllowsTransparency="True" I lose the inactive window visuals. Is there a trigger I can use in the XAML style that can show a hidden mask or opacity changes in the main window when another window has focus? I'd like to be able to achieve this within the XAML and not programat...

Changing the standard behavior of a TextBox?

I have an application that declares textboxes in various places, like in styles and datatemplates, and now I'm in a situation where I need to change every textbox's standard behavior for getting and losing focus. What's a good way to do this? I was thinking of two solutions: one is to derive a new class from TextBox, which I understan...

Using Xaml and WPF, How do you animate a property on click, and then reverse on successive clicks.

I would like to know if there is a way to use only XAML to perform an animation on a property, and then on the next click perform the reverse animation? Here is a sample of the Trigger I have on a Border object to give the appearance of sliding out: <!-- Animates the Width to Slide It Out. --> <EventTrigger RoutedEvent="Border.MouseLef...

Pinyin Character entry on a touchscreen keyboard

The app I'm developing requires that it be deployed in China, which means that it needs to have Pinyin and Chinese character handling. I'm told that the way that our customers handle character entry is like so: Enter in the pinyin character, like 'zhang' As they enter the characters, a list of possible Chinese (Mandarin?) characters a...

Tab between List elements WPF

I have a listbox that in which every item is represented using a textbox. The thing is that I want to be able to tab between all the items in the listbox before moving to the next element in the xaml window. The current (and normal WPF behavior) is that when I tab into the listbox, the first element is highlighted, if I tab again, then ...

Changing the message (or exception) in WPF ValidatesOnException binding

I have a WPF application using MVVM. I am using binding to a POCO object. The Textbox is bound to a property in the object like: <TextBox.Text> <Binding Path="CertainProperty" Mode="TwoWay" > <Binding.ValidationRules> <ExceptionValidationRule/> <...

WPF How to bind GridView column width in code?

I need to bind width property of the GridView column that is created dynamically in code. Since GridViewColumn object has no SetBinding method, how should I do this? Thanks in advance. ...

Determining which ListViewItem was clicked on in a ListView when executing a ContextMenu MenuItem

I'm trying to use the context menu in a listview to run some code that requires data from which item it originated from. I initially just did this: XAML: <ListView x:Name="lvResources" ScrollViewer.VerticalScrollBarVisibility="Visible"> <ListView.Resources> <ContextMenu x:Key="resourceContextMenu"> <MenuI...