wpf

Setting width of a panel based on the width of an element within it in WPF

I have a list box item that I wish to dynamically resize. However I don't want it to resize to the width of the largest element, but to the width of a specific element. This comes from the datatemplate: <StackPanel> <!-- this first item wants to have a width forced to that of the next item --> <TextBlock TextWrapping="WrapWithOverf...

Replacement for ViewBox in free for commercial use framework under Windows

Hello, I want to develop windows C/C++ program, but i need in it functionality like a Viewbox from .NET WPF. But i don't want buying Visual Studio platform because it has this control. Can anyone tell me something replacment for this? I want to do window, which after resizing, resizes its contents with good proportion (images buttons ...

Alternative to System.Drawing.Bitmap in Silverlight which is compatible with WPF

I'm trying to cross compile some libraries for WPF and Silverlight. Currently one of the libraries depends on System.Drawing.Bitmap which is not available in Silverlight. It's a class that represents a device specific image format, and holds a reference to a Bitmap instance in order to display this image in a WPF application. What coul...

DropShadow for WPF Borderless Window

I have a WPF Window with WindowStyle set to none. Is there some way I can force this window to drop a shadow (like the one you get when WindowStyle is not none)? I don't want to set AllowTransparency to true, because it affects the performance. And I also don't want to disable hardware rendering (I read somewhere that transparency perfor...

Handling DependencyProperty changes in the ViewModel of a UserControl.

Hi. Im currently trying to get my first WPF Usercontrol to work. It consists of some UI elements and a ViewModel, holding the data and doing the work. It has a List of items as input, and another List of items as output. I need a certain task in my ViewModel to be done, when the list bound to the input changes. But i can't find a way to ...

WPF newbie - setting ItemsSource in XAML doesn't seem to work

I'm new to WPF and trying to figure out all this databinding stuff. When I do the following in my code, my ComboBox is populated when I run my application: public NewForm() { InitializeComponent(); Product.ItemsSource = Products; } public List<string> Products { get { return _productsComponents.Keys.ToList(); } } However...

WPF - Do not show Context menu when ListView is empty

I have a ContextMenu bind to ListView, but I don't want to be the menu shown when the ListView is empty. I tried direct binding to element, tried binding using FindAncestor, but none of these works and the menu is always shown when I click right mouse button in the ListView. What would be the correct binding? <Grid> <ListView x:Name="lo...

help me please with a Popup

I have an Image and a Popup. When clicked on the Image popup should open. I started like that and now I stuck. <Image x:Name="LockImage" Source="/Lock.png"> <Image.Triggers> <EventTrigger RoutedEvent="MouseDown"> // ?????? WHAT's here? </EventTrigger> <...

WPF RichTextBox: Templates for content?

Hi I'm learning WPF and specifically the RichTextBox via an intellisense-type application. As the user types stuff in, I am wanting to change the appearance of certain words. I'm not really sure what is the best way to do it (I mean the formatting as opposed to the parsing). Ideally (I think) I'd like to do as much as I can in XAML ...

How to get MouseDown after a few seconds?

Assume I have a button and I want the following behavior: when I click on the button, it fires up an event - ok, that's easy. Now, if I click and wait, after a few seconds it suppose to fire up another event. e.g. popup a menu... how to do that? ...

Is it ok to have MVVM without model for temporary things?

Do you think it is alright from architectural stand-point to have ViewModel - View without model for temporary things? E.g.: I want users to input some paths so I can open some files later on. It doesn't make sense for me to store the paths anywhere just ViewModel and when the users clicks "Show all files" I then construct models of the...

WPF Editable ComboBox

I have a ComboBox and ComboBox.IsEditable property is set to True to have a ComboBox act as both a TextBox and a drop-down list simultaneously. But when the ComboBox is data-bound, entering custom text will not cause a new item to be added to the data-bound collection. For example, if I enter 'Joe' in a ComboBox that is bound to a list...

Windows and event subscription (WPF)

Is there a way to suscribe one window event for look when another window close itself? I need to ask some details in the other window, once I get the details, then I close that window, the main window needs to know that. Thanks. ...

How get control from non-window class in WPF?

Application.Current.MainWindow. ? ...

Issue a WPF command from preview handler, and not get stuck in loop

Let's imagine I have XAML that looks like this: <UserControl.CommandBindings> <CommandBinding Command="ApplicationCommands.Delete" Executed="CommandBinding_DeleteExecuted" PreviewExecuted="CommandBinding_PreviewDeleteExecuted"/> </UserControl.CommandBindings> And I have C# code that looks like this: private void CommandBinding_Dele...

WPF: Show new window using XAML

Is there a way to launch a new window in WPF using XAML? Or does it have to be done from code behind? ...

Silverlight 4 Equivalent to WPF "x:static"

I'm working on a project that is based on an old project someone started and didn't finish. I was trying to use as much of their code as I could, so in doing so I ran into some tweaking issues. Namely, when I put some of the old xaml in the new project there were some errors that were thrown regarding the "x:static" property and "Dyna...

What is the most cool feature of WPF

What is is in your opinion the most cool feature of WPF that one absolutely should view at. ...

How do you bind a collection of items to a list box of checkboxes?

Sorry for the vague description, I can't think of a better way to put it. Let's say that my ViewModel has a property as follows: public List<MyClass> SubSystems { get; set; } and the SubSystems class: public class SubSystem { public string Name { get; set; } public bool IsSelected { get; set; } } In the view, I'd like to ...

Problems hosting a WPF control in a windows form

I have a Winform application and want to to use WPF inside this application. I add a WPF user control to my VS project. Then I take a ElementHost control from the toolbox and put it on a form. After that I build the solution. The problem is now, when I want to embed the WPF control with "Edit Host Content" into the ElementHost controlI...