wpf

How to convert every page in a XPS file to an image in C#?

Is there a way to convert every page in a XPS document to an image programmatically using C#? ...

Entity Framework issue - "Mixed mode assembly...cannot be loaded in the 4.0 runtime without additional configuration information"

I have a UI & Library project for the solution where I'm having the problem. The library project uses Entity Framework & the unit tests work OK with it. The project is a C# 4.0 WPF application. To try to get a basic EF line of code working I copied the connection string from the Library project app.config to the UI project app.config....

How can I sort a bound ListBox with custom sort logic?

I'd like to sort it from the View instead of in the ViewModel. Every example I've seen uses a SortDescription, but it's not customizable. ...

How to remove auto generated right blank column from the wpf datagrid?

<DataGrid ItemsSource="{Binding Contracts}" Name="dataGrid" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="Number" Binding="{Binding Number}"> </DataGridTextColumn> <DataGridTextColumn Header="PaymentTerms" Binding="{Binding PaymentTerms}"> </DataGrid...

WPF Binding: Reacting when an item's property changes in a bound collection

Hi, I have the following class: public class MyCustomCanvas : Canvas { public static readonly DependencyProperty SpritesProperty = DependencyProperty.Register( "Sprites", typeof(ObservableCollection<Sprite>), typeof (MyCustomCanvas), new FrameworkPropertyMetadata( null, FrameworkPr...

Issue with MVVM view first approach.

Hi, I am using mvvm architecture view first approach in my project. I mean I have view-viewmodel binding defined in resource file. But i'm unable to open multiple instances of same view...If I open the the new viewmodel will refer to the first view. ...

Custom DependencyProperty issue

I did a test on custom dependency properties on WPF userControls, and does not work... Please help. Task: Having an UserControl - MyCircle, build the CenterX and CenterY bindable properties. Here is my code: MyTestCircle.xaml <Canvas x:Name="mainCanvas" Width="100" Height="100"> <Ellipse x:Name="myCircle" Fill="Red" ...

WPF: Can i set the width of an element by percentages?

Say I have 2 buttons in an Element and I want to set the 2 elements to always fill up 1/2 width of its containing element each, can i do that? UPDATE why cant i do something like <StackPanel Orientation="Horizontal" Grid.Row="0"> <Button Content="Click me" Command="{Binding ClickCommand}" Width="1*" /> <Button Content="Exit" ...

WPF Textblock zoom and wrap

I have a textblock which needs to show text in the maximum font size possible within the given space (less characters bigger letters and vice-versa) wrap the text within the given space. I tried using a textbox inside a viewbox like below but the text-wrapping doesn't work if i don't specify the textblock width and height. If i do sp...

USE of XAML not related to WPF or silvelight

Hi, I am trying to understand the use of XAML instead using it as markup in creating WPF and silverlight applications. Where else could i use XAML. Please provider all the possible uses of XAML. Could XAML be used as regular XML to provider mapping and related stuff? Please provider some links where i could learn about XAML. Thanks...

FormattedText.GetMaxTextWidths returns null - why?

I'm trying to find out how wide some text is. This is my code: FormattedText ft = new FormattedText("Line 1\r\nLine 2", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), f...

What WPF control or approach for this requirement?

Just being new to WPF I"m not sure what control or approach would be best for this requirement, for a WPF application. I want to present a summary table of information, but the user should be able to decide to view the information based on either: "All Time", Month, Week or Day. I'd like to visually have the selection of the option a...

Confused with wpf ComboBox DisplayMemberPath,SelectedValue and SelectedValuePath .

Hi all, I have always struggled with those comboBox properties DisplayMemberPath SelectedValue SelectedValuePath I am building a master detail form . ComboBox filled with Customers User Selects a Customer in Combo All the textBoxes EG Fills correctly The problem I am having I have made it work but I dont understand those pro...

WPF: Show custom Preview-picture for video (MediaElement)

WPF: Show Preview-picture for video (MediaElement)I've got a video as a MediaElement <MediaElement Name="video" LoadedBehavior="Manual" ScrubbingEnabled="True" Loaded="MediaElement_Loaded"" Source="Resources\blickpunkt10.mp4" /> I want to show a custom picture while the user didn't tap the video. How to do this? ...

WPF TextBlock Displaying String Over Multiple Lines

I have a string: Item A\r\nItem B\r\nItem C How can I bind this string to a TextBlock so that it appears as: Item A Item B Item C Thanks ...

WPF Mousedown => No MouseLeave Event

Hey Guys, I'm currently building a WPF-Control with MS Blend and when I'm leaving my control and the left-mouse-button is pressed the MouseLeave-Event is not raised. Any idea how this could happen? Thanks in advance ...

How to collapse a paragraph?

How can I make a Paragraph collapsible in a FlowDocument while keeping its text selectable? ...

WPF: arranging collection items in a grid

Hi, I would like to arrange items of a collection in a grid with a specific number of columns and rows (say 4x6). Each item exposes the dependency properties (integer) X and Y and should be placed in the relevant cell of the grid. Note that the collection can change during runtime which should update the grid items. I couldn't find any ...

Need to override default ContentTemplate for string content.

If I have a Menu defined like this: <Menu> <MenuItem Header="Stuff" /> </Menu> When this gets rendered, the ContentPresenter inside of the MenuItem ends up with content like this: <TextBlock Text="{Binding}" /> which means that it inherits the default styling of TextBlock, which isn't always desirable. I know that I can change my ...

how to get wpf button screen rectangle.

Hi I am trying to get the screen rectangle of a wpf button so that i can highlight it. I use this to achieve the same: AutomationPeer theBtnPeer = createPeerForElement(btn); Rect rect = theBtnPeer.GetBoundingScreenRectangle(); This works fine and give me the right rectangle. However.. if the button is not currently visible then I in...