wpf

WPF: Wrapping multi-part text.

Currently I'm using a TextBlock to show a single line with an image. <TextBlock> <Image Name="StatusImage" Stretch="Fill" MaxWidth="12" MaxHeight="12" Source="/Aam.Cerberus.Applications;component/Images/Warning.png"></Image> <TextBlock Text="{Binding Path=ServiceStatusText}"></TextBlock> <Tex...

Append/replace menu items from within xaml and C#, based on user action

I have an app that allows the user to manipulate different types of data (images, text, whatever). When the user is working with one of these custom User Controls, I want to append a new drop down menu to the main menu. For example, in my ImageEditor User Control, I have the following xaml: <UserControl.CommandBindings> <CommandBin...

How to implement nonscrolling ItemsControl with "more..." entry, aka Paging Control?

I need a control that implements the usual functionality an ItemsControl, with the following behavior: If number of items to display does not fit into available space, instead of showing the scrollbar, the number of displayed items is reduced to be able to fit, while leaving available space for a "More..." or "< >" elements. When numbe...

WPF: Selecting all the text in and setting focus to a ComboBox's editable textbox

I have a WPF ComboBox which has its IsEditable property bound to a view model which can switch it on and off. When it is switched on, I want to give focus to the ComboBox and select all the text in the edit TextBox. I can't see the best to accomplish this. Should I replace the ControlTemplate, subclass the ComboBox base class, and provi...

How do you add a generic item to a ComboBox bound to a collection in WPF

I have a ComboBox in a WPF application that is bound to an ObservableCollection of Department objects in a C# ViewModel class. I want to use the combo box to filter another collection by department (And indeed it works for that now) The problem is that I want to add an additional option "All" to the top of the list. Is there a correct wa...

.NET 4.0 Release Candidate

I just came across this article about WPF performance on Touch/Tablet devices. In the article, the .NET Framework release candidate is mentioned as a way to test if this issue is affecting your application. I'm only aware of the .NET Framework 4.0 Beta 2; is there a RC build of .NET Framework 4 available somewhere? Perhaps he just mean...

tooltip for Tab control in tab header

Hi, Im my tab control i want to set tooltip for all tab neaders. I coded like below <TabItem.ToolTip> <StackPanel Height="40" Width="70" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="center" > <Image VerticalAlignment="Top" Width="30" Height="10" Source="Image\TAB2.png" Name="image2" /> <TextBlock FontFamily=...

WPF Styles Question

A simple question which I can't find the answer on the web for some reason... I want to place the content to a ResourceDictionary: <TextBlock Style="{StaticResource HomePageTextStyle}"> <LineBreak/> Hello<LineBreak/> <Bold>World!</Bold> <LineBreak/> </TextBlock> The best I could do was: <s:String x:Key="HomePage...

Find the Label for a Targeted UIElement in WPF

Hello, I have the following XAML: <StackPanel> <Label Target="{Binding ElementName=txtSearch}" Content="_Search:" /> <TextBox x:Name="txtSearch" /> </StackPanel> I have an extension method that accepts a UIElement parameter like so: static public class MyExtensionMethods { static public string GetLabelText(this UIElement...

Keep same selected Item in a ListView when the collection it is bound to is refreshed

I have a ListView that is bound to an ObservableCollection which is itself derived from an IQueryable. When I refresh the collection, after items are added, edited or a button is clicked (to see if the database has new items from other users). The listbox refreshes and selects the first item in the collection. I want to keep the same s...

ListBox MouseBinding to Command not working

Hi ! I want to bind the MouseDoubleClick (or PreviewMouseDoubleClick) to my custom Command defined in my custom WPF Control. The problem is that it does not work. ... <Popup> ... <!--This CommandBinding **DOES NOT WORK** !--> <ListBox Grid.Row="1" x:Name="PART_lBox" ...

How do I detect the end of a page in a fixed document

How do I detect the end of a page in a fixed document in WPF? I want to be able to print a list of customers, but I'm not sure how to tell when to create a new page. Do I guess? i.e. If i think that 50 customers will fit on the page then I only get the first 50 and then create a new page and display the rest on the second page. Also, w...

WPF: Removing "yourself" from the parent container.

I have a button in my user control which should be used to remove the user control from its parent container. This is the way I have coded it today. private void RemoveRoleButton_Click(object sender, RoutedEventArgs e) { if (ConfirmRoleRemoval()) { Panel parentPanel = (Panel)this.Parent; parentPanel.Children.Remo...

WPF: What's wrong with "DataContext = this" in user controls?

I read somewhere that setting DataContext = this in the constructor of a user control is bad practice (can't find where though). Why is this bad practice? What is the alternative? ...

What is happening between method call and method entry (C#)?

At the moment we have a problem with the startup of a middle-sized WPF-application. It takes about 15 seconds to load completly. We wondered what it takes that long. In the event Application_Startup of App.xaml a controller gets initialised. This controller lives in a separate 'business' assembly, which calls in turn to the 'data' assem...

Moving from WinForms to WPF

Well we are considering to move from WinForms to WPF, what pitfalls does WPF have? And we got component one's flexgrid is there any wpf grid that has the same functions? one nice thing with it is that you can implement your own draw method for the cells... It can merge cells print and save to many file formats.. ...

In WPF, under what circumstances does Visual.PointFromScreen throw InvalidOperationException?

Suppose I wanted to do this, so I can find the current position of the mouse relative to a Visual, without needing access to a specific mouse event: public static Point GetMousePosition(this Visual relativeTo) { return relativeTo.PointFromScreen(GetMousePositionOnScreen()); } Sometimes (usually when I've just switched between two ...

Visual Studio underlines existing Dependency Properties

How is it possible, that some custom Dependency Properties from a Custom WPF Control are in Visual Studio WPF Designer underlined like a Non-existing properties, but in reality they are defined and everything works well ? Thanks ...

wpf vs winforms by means of customizeable UI

Which technology (WPF or Winforms) should be used if UI supposed to be highly customizable like controls layout/design could be change by user and such sort of UI customization. Kindly mention best practices along to achieve that... ...

WPF Set Window Title from Child

If I have a UserControl hosted in a Window that looks like: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <Grid> <ContentPresenter Content="{Binding}" /> </Grid> </Window> How do I set the Window.Title from the UserControl? An ad...