wpf

WPF/Silverlight: Why do animation classes require dependency properties?

Why do animation classes (like DoubleAnimation) require dependency properties? Dependency properties have a lot of overhead when compared to a simple property. Wouldn't passing in an object and property name and using to reflection to retrieve a setter delegate have made the animation classes more flexible and generally more usable? I...

WPF TabControl add extra tabs to a bound control

Hello, I have a Tab Control with a ItemsSource Binding. ... I want to add a predefined tab to the front called All that has an aggregate of all the other tabs, and I would also like to add a button at the end called Add so I can add a new tab. Is there an easy way of doing this ? Thanks, Raul ...

Detect if any key is pressed in C# (not A, B, but any)

Hi, [EDIT 3] I kind of "solved it" by at using the "strange" version. At least for the most important keys. It is suffient for my case, where I want to check that ALT and ALT+A are not the same (thereby making sure A is not pressed). Not perfect, but already to much time for such a tiny problem. Thanks for all the answers anyway... [ED...

Using Linq-to-SQL entities in your BLL or UI?

I had a client ask for advice building a simple WPF LOB application the other day. They basically want a CRUD application for a database, with main purpose being as a WPF training project. I also showed them Linq To SQL and they were impressed. I then explained its probably not a good idea to use that L2S entities directly from their B...

Silverlight or WPF Open Source Project for learn

Looking for Silverlight or WPF Open Source Project for learn. Particular I am interested in Silverlight\WPF Custom Controls\Styles Development and want to find good patterns\solution for current project. ...

Case Conventions in wpf using MVVM

Is there a standard for case and naming conventions in wpf/mvvm that differs from C#? I am accustomed to camelCase with the first character being lower case for private and upper case for public methods/properties. In the sample MVVM code I have been examining I have seen a lot of leading _ characters, is this a holdover from another p...

Binding to a complex object in Silverlight

i know it must something simple that i missed. I use data services to get data into my silverlight application. When i bind the data to my datagrid it works like a charm LessonGrid.ItemsSource = context.Lessons however as soon as i try to wrap my objects into more complex data structure it stops working LessonGrid.ItemsSource = conte...

Wpf ListBox Trigger not working for IsFocused Property.

I want to style my ListBox and displaying some Border around it, i want to hide this Border when ListBox gets focus, <Trigger Property="IsFocused" Value="True"> <Setter Property="Visibility" TargetName="border" Value="Collapsed"/> </Trigger> Same thing i m using in TextBox also and it is working properly, why this Trigger not workin...

wpf set barchart graph width programmatically C#

I have a chart and I am adding ColumnSeries and chart legend etc but how to programmatically set its bar width... ??? | |------| | | | | |set | | |this | | |width | | | | | | | | | |BarChart Graph |_______|______|_______________________________ <charting:Chart...

How to add button dynamically in datagrid in wpf?

I am trying to do something in WPF. I have a datagrid that I am binding with some values. What I need is that whenever I call that page the second time, I need to insert a button to all the cells of all the columns in the datagrid(except for the cells in the first column which are bound to some value). How can I do that? Please help. ...

What is the code behind for datagridtemplatecolumn, and how to use it?

Hi. I have a datagrid in wpf. And I am trying to add buttons to certain cells of the grid, after it is bound to a particular itemsource. I have tried to do this in the xaml like this: ` <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <awc:ImageButton...

How to assign a dynamic resource style in code?

I want to produce in code the equivalent of this in XAML: <TextBlock Text="Title:" Width="{Binding FormLabelColumnWidth}" Style="{DynamicResource FormLabelStyle}"/> I can do the text and the width, but how do I assign the dynamic resource to the style: TextBlock tb = new TextBlock(); tb.Text = "Title:"; tb.Wid...

Wrapping Controls from System.Windows.Forms in System.Windows.UIElement

Is it possible to wrap the old System.Windows.Forms controls in System.Windows.UIElement? I know that the Browser Control is somehow wrapped and the base is from System.Windows.Forms. If this is possible, would the implementation cause any consequences? ...

WPF TreeViewItem dyanmic context menu

Hi, I'm having some trouble with a databound TreeView in WPF, basically I want a context menu to be databound to an IEnumerable property on my TreeViewItem ViewModel, this is what I'm trying to do in the of each TreeViewItem: <Setter Property="ContextMenu"> <Setter.Value> <ContextMenu ItemsSource="{Binding ContextMenu}" /> </Setter.Va...

WPF: update UI from ViewModel class (mvvm pattern)

Hi, I'm using the MVVM pattern in my first WPF app and have a problem with something quite basic I assume. When the user hits the "save" button on my view, a command gets executed that calls the private void Save() in my ViewModel. The problem is that the code in "Save()" takes some time to execute, so I'd like to hide the "Save" but...

How to set the keyboardfocus to a textbox inside a UserControl programmatically?

I have a UserControl that incorporates a textbox. I want to set the keyboardfocus to this textbox programmatically when the user clicks a button. I tried this: private void Button_Click(object sender,EventArgs e) { Keyboard.Focus(MyUserControl); } no luck. Then I exposed the Textbox in the UserControl though a property of type TextB...

In WPF / C#, how can I check if the center button is clicked or released?

In WPF / C#, there are events on MouseRightButtonDown and MouseLeftButtonDown, but what about the center mouse button? Is the Center Mouse button down/up e.g. events in WPF forgotten? How can I check if the center button is clicked or released? ...

WPF: Adding Button Column to Datagrid

Hi how can i a Button column to a Datagrid programatically. I want to do this through code in codebehind file. Also i want to selectively enable or disable this button based on record (If status is Open then Enable it else disable this button). Here Status is a Column in the DataSource. Thanks, Abhi ...

How can I get the Text value of a TextBox whose Name gets assigned at runtime?

I am creating a TextBox with the following code: TextBox textBox = new TextBox(); textBox.Name = propertyName; textBox.Text = value; textBox.Width = FormControlColumnWidth; textBox.SetResourceReference(Control.StyleProperty, "FormTextBoxStyle"); sp.Children.Add(textBox); //StackPanel FormBase.Children.Add(sp); On a button click, I wa...

C#/WPF: Keep aspect ratio of UserControl?

Hello, Does anyone have an idea how to keep the Height/Width Ratio 1:1 of a UserControl? E.g. if Height > Width, Width & Height will have the same size and vice versa. Thanks for any help. Cheers ...