xaml

Update binding of TreeViewItem using code? (XAML / WPF)

Hey I have a TreeView whose ItemsSource is set to a Model I have. 3 levels deep is an object whose state can change and, rather than write a View and ViewModel for each stage (very lengthy business) I wanted to just update this using code. So basically I have an event that is fired once my model updates, I catch it then find the TreeV...

WPF - Workaround for ValidationRule not being a DependencyObject

What is the best solution for not being able to use data binding on a ValidationRule property since ValiationRule is not a DependencyObject? Below is an example of what I would like to do. I want to be able to validate the text in the TextBox against some other DependencyProperty. <TextBox Name="myTextBox"> <TextBox.Text> <...

Specifying and displaying columns of a DataGrid in WPF declaratively using a binding?

Is there a way to specify DataGrid columns declaratively using a binding? (And to set the columns' properties using this binding?) Idealy, I would have a list of objects (e.g. rows) databound to the ItemsSource and one of their properties would be a dictionary (or a list of objects of a certain class or whatever) with a name and a value....

Silverlight Xaml: Referencing Code-behind class

Assuming the following view model definition: public class MyObject { public string Name { get; set; } } public interface IMyViewModel { ICommand MyCommand { get; } IList<MyObject> MyList { get; } } And a UserControl with the following code behind: public class MyView : UserControl { public IMyViewModel Model { get; } } If my...

WPF - How to set DataContext on virtual branch of logical tree?

How do I set the DataContext of "myElement" to the same DataContext as the user control in XAML? I have been able to do it in code-behind via myElement.DataContext = this.DataContext in the UserControl constructor, but I'm trying to understand how to do the same thing in XAML. This is related to creating virtual branches to the logical ...

WPF - Why isn't ValidationRule a DependencyObject?

Is there a technical reason why ValidationRule is not a DependencyObject? ...

Carriage Return in Accordion Control Header - Silverlight 3.0

Hi Folks. I've got an Accordion control in my Silverlight app, and I'd like to be able to insert a carriage return in the title of one of the AccordionItems. I've tried inserting various symbols such as "" and ""... but nothing has worked. Appreciate any help. Thank you. ...

WPF: PopUp on MouseOver of a ComboBoxItem

Does anyone know of an example of how to display a PopUp on MouseOver of a ComboBoxItem? TIA EDIT: I know how to create, style and position the PopUp but not how to display it! I may be retired. ...

how do i make that dang wpf popup go away?

when i use a popup, it seems to hang around. in the code below i attach a popup to a textBox using by overriding the control template, and make the popup appear when the TextBox has focus. When you tab to the next on screen element the popup goes away, but if you just alt-tab to a different application the popup stays there in the foregr...

properly resize wpf ListView's last column

How to properly handle listview's last column sizing in such a way that: listview does not display the ugly and unused 'extra' column (see picture 1, or here for example) the (actual) last column is stretched to fill the remaining space the horizontal scrollbar is not shown resizing in any direction leaves no artefacts (see below) I'...

Saving Bitmap Images in WPF via C#

Hey I display images in my WPF app using BitmapImage. However, I would like an easy way to save these (as JPG) to a different location (ideally into a Stream or object that can be passed around) Is it possible using BitmapImage or do I have to use other means? If so what other means are there for either loading an Image and saving as J...

Styling my listbox in xaml

Hi all xaml-geeks ;) I've just been fooling around with a ListBox control that I want to style a certain way. For now it looks just like I want it to with rounded corners and no padding. However, the rounded corners seems to cause a problem with the items in the ListBox. A screenshot so you can see what I mean: The thing is, that th...

Capture mouse clicks on WPF TextBox

Hi all, I want to capture mouse clicks on a TextBox: <Window x:Class="WpfApplication2.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <TextBox x:Name="t" MouseDown="TextBox_MouseDown" MouseLeftButtonD...

Pack URI and path not resolving image in WPF

I have the following directory structure Project \Images +view.png control.xaml and in the control I have a button defined by the following XAML: <Button Click="Search" Grid.Column="1" Margin="0,5,5, 0" HorizontalAlignment="Right"> <Button.Template> <ControlTemplate TargetType="{x:Type Button}"> ...

ItemContainerStyle in Custom Control Derived From ListBox

Please bear with me Silverlight Designer Gurus, this is compicated (to me). I'm creating a custom control which derives form the Silverlight 3.0 ListBox. In an effort not to show tons of code (initially), let me describe the setup. I have a class library containing a class for my control logic. Then I have a Themes/generic.xaml t...

ListBox Foreground Color Problem for Selected Item Without ItemContainer

The following code, behaves little strange. <ListBox SelectionMode="Multiple"> <StackPanel> <TextBlock>Selection is Black</TextBlock> </StackPanel> <ListBoxItem> <StackPanel> <TextBlock>Selection is White</TextBlock> </StackPanel> </ListBoxItem> </ListBox> Note that first selection stay...

Anyway to start/stop/resume/pause a Storyboard in pure XAML in Silverlight, for any event?

Any way in Silverlight to write pure XAML code for controlling story boards, by responding to any given event for a given control? For eg, when the user move the mouse over a panel, I might need to start the storyboard, and pause it when he moves the mouse out. ...

Use ComboBoxItem text as value for a Property Setter

Hey guys! Here is the deal... I have a ComboBox defined in my window. The content of this comboBox, is only a string list with all values in Brushes class. Nothing special so far... But what I'm trying to achieve is a way to change the combobox background color when the user changes the color. The color would be the value selected in t...

How can I change an elements style at runtime?

I have an element and multiple styles, how do I switch between the styles at runtime either programatically or through XAML binding. <Rectangle x:Name="fixtureControl" Style="{DynamicResource FixtureStyle_Fast}"> <!-- In the style resources. --> <Style x:Key="FixtureStyle_Fast" TargetType="{x:Type Shape}"> <Setter Property="Stroke"...

Change the FocusVisualStyle in the entire application

While making a WPF application I would like to change the default FocusVisualStyle (the black "marching ants" border) to something else, like for example a blue border. I would like to make this change for every control on the entire application. Is there an easier way then changing the default style for every type of control? Thanks ...