wpf

WPF: How to draw a circle and drag it around?

I am new to WPF. I want to draw a small circle on Canvas when I click mouse and be able to drag it around smoothly. How can I accomplish this? ...

WPF: hide the TabControl header

What's the programmatic way (ie not using styles as in this question, but using code) to hide the TabControl header? I'll be glad for a snippet. ...

Applying WPF styles to Child Items

Hi There Lets say I have a grid, within my grid I have a number of controls. Instead of setting the margin for each of these controls, I wish to create a style to set the margin for ANY control I drop into a grid. Is this possible? I was hoping that the following would work: <Window.Resources> <Style x:Key="DefaultMargins"> ...

Delayed "rendering" of WPF/Silverlight Dependency Properties?

Is there a way to know the first time a Dependency Property is accessed through XAML binding so I can actually "render" the value of the property when needed? I have an object (class derived from Control) that has several PointCollection Dependency Properties that may contain 100's or 1000's of points. Each property may arrange the poin...

How to change color of border in a usercontrol using trigger with its custom property?

...

InkPresenter can't be called in external thread

Hi I need to convert a InkPresenter to bitmap : InkPresenter ink = new InkPresenter(); ink.Strokes = p; RenderTargetBitmap targetBitmap = new RenderTargetBitmap((int)rect.Right, (int)rect.Bottom, 96d, 96d, PixelFormats.Default); ink.Measure(new Size((int)rect.R...

Playing gif file in repeat mode using MediaElement

I want to play gif recurrsivley file using MediaElement. Is there any inbuild property like (repeat or any other) to play files non stop ? I have played in repeat mode using following code. objMediaPlayer.Source=new System.Uri("XXX.gif"); objMediaPlayer.LoadedBehavior= MediaState.Manual; objMediaPlayer.MediaEnded+=new RoutedEventHa...

How to make a StackPanel Width that of another StackPanel?

I have two dockpanels which each have a left StackPanel. The width of the bottom StackPanel is determined by the width of the text is in it. The width of the top StackPanel should be the same as the width of the bottom StackPanel. I've tried to bind the Width of the top StackPanel to the Width of the bottom StackPanel via ElementName ...

Displaying the selected item differently in ComboBox

I have a combo box in which I set up an ItemTemplate that looks something like this: <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Piece.NoPiece}" Width="50" /> <TextBlock Text="{Binding Piece.Description}" Width="170" /> <TextBlock Text="{Binding Piece.Cat...

WPF DataGrid: Blank Row Missing

I am creating a WPF window with a DataGrid, and I want to show the blank "new item" row at the bottom of the grid that allows me to add a new item to the grid. For some reason, the blank row is not shown on the grid on my window. Here is the markup I used to create the DataGrid: <toolkit:DataGrid x:Name="ProjectTasksDataGrid" ...

How to add toolbar to bottom, top, left, or right of the inside of a listbox in WPF?

I have a listbox with a style that has rounded corners. I'd like to add a toolbar inside the listbox that pertains to that specific list box. Currently, if I add a toolbar inside the grid that contains a listbox, it will overlap the last item in the row (depending on the height of the toolbar). Does anyone have any ideas on the best w...

VisualBrush of a Window in another Window

So basically, the MainWindow opens a second Window, let's say OptionsWindow. So in the OptionsWindow I want to show a visual of the MainWindow. I tried this, but didn't work: <Rectangle Grid.Row="1" Margin="3" Height="100"> <Rectangle.Fill> <VisualBrush Visual="{Binding Application.Current.MainWindow}" /> </Rectangle.Fill> </Rectang...

WPF / DeferRefresh with bound listbox

I am trying to push in a number of updates to a collection to which I have bound a list box. Since the list can get quite big, i am trying to turn off updates (sorting, etc) until I finished inserting all the new items. I figured: using (col.DeferRefesh()) { .. add the items } but this raises an exception saying that I cannot add/...

How do I associate a keypress with a DelegateCommand in Composite WPF?

I am building a composite application using CAL/Prism. The main region is a tab control, with multiple types of views in it. Each view has a custom set commands that it can handle which are bound to toolbar buttons at the top of the window. I've done this before in non-CAL apps by simply setting the InputBinding on the command, but I hav...

How can I convert a WPF control into an image?

Hello, Is there an easy way to convert a WPF visual into an image? If so, what's the code? ...

WPF ICommand MVVM implementation

So in this particular MVVM implementation I'm doing, I need several commands. I really got tired of implementing the ICommand classes one by one, so I came up with a solution, but I don't know how good it is, so the input of any WPF expert here will be greatly appreciated. And if you could provide a better solution, even better! What I ...

What's the quickest/easiest way to get example data into ListView/GridView in WPF?

I'm doing some quick design work/rapid prototyping with WPF. I'm curious if anyone has a good strategy for getting example data into a ListView/GridView (or really any ItemsControl for that matter). The example data would either be made up on the fly, or pasted in from somewhere (e.g., an Excel file). ...

LINQ To SQL - Poor Sql Performance

Hey all, I have a WPF at a customer site that makes calls to a remote SQL 2005 server using Linq To Sql. Almost everyday the customer experiences aweful slow downs, and I am not sure what to do. The quick fix is to restart the mssql service and that seems to do the job, but that is not a solution. Tonight I used the SQL profiler and ...

Can I partially apply a ControlTemplate in WPF?

I'm pretty green when it comes to WPF, so forgive me if this is an obvious question. I'm trying to modify an existing code base that is using the Divelements SandRibbon libraries, but am finding that the GalleryButton control doesn't behave quite how I'd like. What I'd like to do is change the way GalleryButton arranges the image and la...

Creating custom forms in WPF?

I'm currently learning WPF. I really am enjoying it so far. I love how easy it is to make great looking apps, and would like to create an app that has a custom window border. I would like for it to look something like this: I know I could just easily change the Window type to not have a boarder and go from there, but that seems to muc...