Wpf What is the best way to not have DependencyProperties conflict with actual properties?

I find that when I make Dependency Properties, most of them conflict with names of properties in the UserControl, e.g Background, Width, etc. so my strategy is to prefix all of my custom properties with "The" so I have, e.g. TheBackground TheWidth etc. I tried using the "new" keyword which gets rid of the warning, but that leads to conflicts at runtime. Has anyone come upon better naming strategies for DependencyProperties in custom user controls? public partial class SmartForm : UserCont

Wpf Do yo know of a more dynamic grid for Labels + TextBoxes data entry layouts?

My LOB app has loads of screens that have columns of labels and textboxes, side-by-side. I'm wanting to achive something in-between what a Grid and a WrapPanel layout - where when the Page/Window is wide enough, the label + textbox pairs re-organize into multiple columns. Imagine: Narrow Window Layou: Label | TextBox Looooong Label | TextBox Label | TextBox Label | TextBox Broad Window Layout: Label | TextBox | Looooong Label | TextBox L

Wpf Making part of a FlowDocument non-selectable

I want to make a FlowDocument that contains both user-specified content, and hyperlinks for manipulating that content. I want the user to be able to highlight the content with the mouse, and copy it to the clipboard. Is there any way to allow that, while preventing the user from highlighting and copying the hyperlinks? (Note that the user won't edit this FlowDocument directly -- it's just a nice means of displaying content they've entered elsewhere.) For example: <FlowDocumentScrollViewer&

How to do wpf datavalidation with Ado.net

How can i use data validation mechanisms with ado.net datatable or datasets. I have an input form which i am binding to a datatable.Now i want to do input validation how can i do that.I have tried using validationRules but i cant bind parameters to it.I tried using idataerrorinfo but cant get a clue.can someone provide some input..?

How can I anchor a textbox in wpf?

I have a window with tabs. On one of the tabs, I have a layout like below. (In fact it is more complicated, I have 4 text boxes in a row, and I have more rows.) How can I make the 3rd textbox have the width of the label + the width of the text box above, that is, to have them properly aligned ? The problem is that WPF widens the 3rd textbox, when I type text into it. Using hardcoded numbers for the sizes defeats the whole purpose of WPF. I could do that way 10 times faster in Windows Forms than

WPF Datagrid binding to ObservableCollection no columns generated

I am binding a datagrid to some data and using the AutoColumnGeneration. When using a regular linq query against a dataset, everything works fine : var queryAll = from actor in actorsAll select new { ActorName = actor.IsPerson ? actor.FirstName + " " + actor.LastName : actor.CompanyName }; MalatDetailsBudgetGridUC.ItemsSource = queryAll; But as i want my grid to be binded to an ObservableCollection, i am trying to use the followings: ActorsCollection collection = new Actor

WPF Binding between Control and Style

I have a control in my XAML bound to a property with a style. <TextBox x:Name="txtCapAmount" Text="{Binding Path=CapAmount}" Style="{DynamicResource AmountTextBoxStyle}" /> In the style I'd like to use the Binding from the control but am not sure how to set it <Style x:Key="AmountTextBoxStyle" TargetType="{x:Type TextBox}"> <EventSetter Event="TextBox.PreviewTextInput" Handler="PreviewTextInput_IsTheNewValueAnAcceptableAmount" /> <EventSetter Event="CommandMan

How to update a part of a WPF custom style

I have created a custom window control (inherited from Window), all is fine except the text of my status bar. I have added a new property to my control called "StatusText" and this text is shown inside a TextBlock in my control's style. But when I change the StatusText property of my window the text doesn't change, it's not update. On another side, if I change the Title property of my window (which is an inherited property) the Title change correctly. So maybe I have not correctly declared my

Attached or dependecy Property for ValidationRule WPF

I want to bind the attached property or dependency property in xaml for the ValidationRule in xaml and then based on the value of the attached property or dependency property I want to make sum decision in the Validation rule. I can't find any solution how can I Pass bindable value to the Validation Rule.

Wpf ResourceDictionary as ContentProperty in a ValueConverter

To convert Enums to Icons I use a value converter like that: public class IconConverter : IValueConverter { public ResourceDictionary Items { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string key = Enum.GetName(value.GetType(), value); return Items[key]; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

Is WPF replacement of WinForms?

Possible Duplicate: When is Winforms the correct choice vs. WPF? Hi, I have read various opinions but I do not get the final picture. Also is WPF replacement for WinForms or its an alternative for richer visual experience?

Wpf How to preload Prism views at application startup?

We use Prism 4 for WPF as well as the navigation functionality which comes with Prism. When navigating to (loading) certain views in our application we notice a delay - which understandably comes from instantiating the view and its dependencies, this includes loading necessary assemblies from disk. We would like to preload these views at application startup while showing a splash screen or something similar. Has anyone done something similar and would like to share their experiences?

converting WPF project to Silverlight. Somehow the application crashes

Im trying to convert my WPF project to Silverlight. The WPF project was written in MVVM template. it doesnt connect to any database, ive used an XML serializer to create and read from XML file. But somehow the application crashes. I think it maybe the App.Xaml. But I am unable to debug the silverlight application, as it gives an error "The breakpoint will not currently be hit., no symbols have been loaded for this document".... Not too sure where to go from here... private void Application

WPF DataGrid full row selection

I'm using WPF and .NET 4.0. Recently in one of my programs I switched from using ListView with GridView to DataGrid. I want to be able to select and highlight the whole row like I was able to do in ListView. In ListView, when I click on the empty space right from the last column, I'm still able to select the row. The whole row is highlighted, not only the cells. In DataGrid however, after setting SelectionMode="Single" and SelectionUnit="FullRow", the row is selectable only when I click on an

Wpf Whats the right way to impliment a login view using prism 4

I am trying to create a login control, pretty simple stuff...just using a usercontrol with a couple of labels, textboxes and buttons. My problem here is im using prism and i dont know the right way to impliment the logic. Since im writing everything myself, ive been spoiled by asp.net, im really kinda lost. Ive seen a few articles but nothing that really gives me a clear cut idea. I think i should be using delegate commands to handle the button click events but thats about as much as ive got. A

Wpf Opening new workspace from child viewmodel

i've written a project that is based on the MVVM customer example on MSDN. How would i add a new workspace from a child view model? I don't like the idea of making the Workspaces collection static as this seems to go against the pattern. i'm effectively trying to add a new customer view when an element in the allcustomers view is double clicked. thanks in advance

WPF DatePicker Control Display Dates

I'm using WPF with MVVM implementation, and have a WPF DatePicker control. I've set the default date on my property using DateTime.Now, but I would like to disable all the Dates on the DatePicker control that fall before the current date so that the User cannot select any earlier dates. I've tried setting this in xaml using FallbackValue={x:Static sys:DateTime.Now} in my SelectedDate property, and {x:Static sys:DateTime.Now} in most of the other properties (from another source) but the dates be

Wpf Different views/usercontrols on each tab of a TabControl

I'm trying to write a program that uses tabs to hold different usercontrols. What I currently want to happen is the user clicks a find button, a new tab is created, and a find screen appears inside it. Using the find screen the user can select clients and these then open in their own new tabs allowing the user to edit them. So if the user went in and selected three clients, the screen would have four tabs, one for the find screen and three client tabs. It will also need to close the tab when the

WebBrowser in WPF using MVVM pattern

I am trying to open HTML file in WebBrowser window of WPF using MVVM patten. Note: I have fixed the issues i was getting. Now this code works as desired. ViewHTMLPageView.xaml <Window x:Class="MyProject.ViewHTMLPageView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:MyProject.Utility" Title="HTML Report" Height="454" Width="787" > <Grid Name="grid1">

Wpf .net Capture real time GPS data

I am wanting to build a car dashboard equivalent in C# WPF and I have everything running well with dummy data. I can find very little information on streaming live data from a GPS. Does anyone have experience with something like this and can you point me in the right direction. Cheers Peter

Wpf Binding instances being re-used in DataTemplates when ValidationRules can't be shared

I'm looking for a solution and/or the rationality behind why a Binding instance is shared within a DataTemplate. This ultimately comes down to the fact that within a DataTemplate, there's seemingly no way to force a new instance of a Binding on a DependencyProperty for each control generated. That is probably a fair and good assumption in all cases except when there are ValidationRules representing something specific about the instance of that control. To elaborate (I can provide code, but I

Background Image of Button not showing in WPF

I have program in which I have lots of buttons. Each of button has background set as <Button x:Name="mybutton" HorizontalAlignment="Left" Height="30" Margin="76,110,0,0" VerticalAlignment="Top" Width="25" Click="some_click"> <Button.Background> <ImageBrush ImageSource="Resource/button_picture.png"/> </Button.Background> </Button> Image is showing as background in .xaml when program not running but when i run

change the column direction in wpf datagrid

I'm searching about WPF property that makes the columns direction to the right direction. In Windows Forms there is property named RightToLeft that makes this job, but i don't find any thing in WPF that do this job. Can any one help me, please?

MVVM WPF - Viewmodel commandbinding

Iam using MVVM model and I have three usercontrols in a WPF Main window and each usercontrol has datacontext set to different viewmodels in the xaml. The main window is also attached to a different viewmodel in the datacontext. Mainwindow has three buttons and should be bound via command binding, How can we bind the main window buttons to corresponding usercontrol view model Icommand via xaml?

Right align ToolBarPanel control WPF

This is my first time using WPF, I have a usercontrol with a ToolBar, and ToolBarPanels on that ToolBar. My problem is trying to right align the very last ToolBarPanel which contains some buttons. http://imgur.com/n5v4YCw I have scoured the interwebs and tried solutions (wrap it in a grid, dockpanel, stackpanel) but none have worked. My XAML is: <ToolBar HorizontalAlignment="Left" Width="{Binding ActualWidth, ElementName=userControl}" VerticalAlignment="Top" Nam

Devexpress( WPF GridControl) modify image inside a GridColumn using DataTrigger

I am using a WPF Devexpress GridControl and I have a column that contains an image. I want to modify the Image using a DataTrigger. Here is the XAML: <dxg:GridColumn Header="{Binding Source={StaticResource MainWindowResources}, Path=Resource.Status}" FieldName="SaveStatus" MinWidth="60" Width="60" ReadOnly="True" >

Wpf PropetyChanged event is null on RelativeSource binding

I use on the following DataGrid: <DataGrid SelectedValuePath="Key" DisplayMemberPath="Value" ItemsSource="{Binding MyModelGrid}"> <DataGrid.Columns> <DataGridTemplateColumn Width="*" Header="{x:Static p:Resources.XHeader}"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox IsEditable="True" SelectedItem="{Binding Value.X}" ItemsSource="{Binding DataContext.XList,RelativeSource={RelativeSour

Which will fire first Binding trigger or Event in WPF control

I am forced to use a third party control for masking the text input. The XAML for the third party control looks like this <thirdParty:MaskInput Value={Binding Path=Phone, UpdateSourceTrigger=LostFocus} x:Name=Phone LostFocus=Phone_LostFocus /> Now in my code behind I have a code for the event handler like this - public void Phone_LostFocus(object sender, RoutedEventArgs e) { ((MaskInput)sender).Value = ((MaskInput)e.OriginalSource).Text; } When I execute this code some

Wpf highlight combobox item if it's text starts with the text of the combobox's textbox

I want to highlight(make bold and change its color) all the items whose text starts with the text of the combobox's textbox. I have tried to google the above question but I am unlucky to get any similar results which would solve my problem. I think just a hint might be more than enough to solve this problem. Though I am a newbie. If it is possible give me a simple example. Update : Here is the code that I tried: <ComboBox x:Name="cbUnder" ItemsSource="{Binding GroupsAndCorrespondingEffec

Connect to SQL Server remotely from outside VPN using WPF application

I have a WPF database application on client machine. The SQL Server is in my home office (so the server is outside of the client's network.) I used the following connection string on my network while building the application: <add name="ConnectionString" connectionString="Data Source= PrivateIPAddressofServer\ComputerName\SQLEXPRESS,1434; Initial Catalog=NameofDatabase; User ID = userid; Password = password;" providerName="System.Data.SqlClient" /> I am able to connection to the serve

Wpf How to utilize a DataTemplate with persistent ViewModel(s)

I started off binding ContentControls to Views stored in my ViewModels, and while it worked as intended, it broke the MVVM pattern I've been trying to follow. It just felt dirty. So, based on the recommendation of someone in chat, I learned about DataTemplates, implemented it, and it has been an awesome solution. However, I have run into a snag, most likely the limits of my knowledge, so here I am and thanks in advance. Premise The description of my problem is based on what I've gathered ab

Custom binding to a property in XAML / WPF

If for example I have a view model class like class ViewModel { Data Data { get; set;} } and class Data : IClonable { public int Value0 {get; private set;} public int Value1 {get; private set;} Data SetValue0(int value){ var r = (Data) this.Clone(); r.Value0 = value; return r; } Data SetValue1(int value){ var r = (Data) this.Clone(); r.Value1 = value; return r; } } in my XAML, with an instance of ViewMo

Why does this code freeze my WPF UI?

I am writing a Powershell script utilizing WPF with the methods shown here: http://learn-powershell.net/2012/10/14/powershell-and-wpf-writing-data-to-a-ui-from-a-different-runspace/. I'm encountering an issue with the follow code freezing the UI as the "btnTest" button is clicked. I'm guessing this is some sort of deadlock because one thread is attempting to access another thread's resources. I hope there's some way around this: Add-Type -AssemblyName PresentationFramework,PresentationCore,W

Multibinding WPF

I am arranging few textblocks in a canvas based on it's locations. sample code snippet is provided below at bottom. For this process I need to access each textblock's Actualwidth and Actual Height inside ItemContainerStyle. I am struggling to access it's properties as below by element name, because it doesn't have a name. How to do it? Do I need to do through templates? <MultiBinding Converter="{StaticResource BPositionConverter}" ConverterParameter="Left">

Wpf MultiTrigger with the some extra condition on load

I have a tool window in my application. there are some text input available and i have some validation rule on those text boxes. say, validation rule 1 Validation rule 2 validation rule 3 I have a button on that tool window and a style like the bellow <StackPanel.Resources> <Style TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonStyle}"> <Style.Triggers> <MultiDataTrigger> <MultiDataTrigger.Conditions>

WPF rendering is too slow

I am experiencing a strange problem trying to use WPF to render a number of polylines (64 polylines about 400-500 vertices in each on a 2300x1024 Canvas). Polylines are updated every 50ms. For some reason my application UI becomes very sluggish and almost unresponsive to user input. I am using to following class to avoid updating the point collection while it is displayed: class DoubleBufferPlot { /// <summary> /// Double-buffered point collection /// </

Wpf Add 'Select All' context menu item to default TextBox menu items

I have a TextBox in CellEdititngTemplate for DataGridTemplateColumn in my DataGrid and I want to show 4 context menu items (Cut, Copy, Paste, Select All) when my DatagridCell is in edit mode and user right-clicks on it. I see that default right-click context menu for TextBox control contains only 3 menu items: Cut (Ctrl+X), Copy (Ctrl+C), Paste (Ctrl+V). There's no 'Select All' context menu item though Ctrl+A works for TextBox. So the question is - how to add a new Context Menu item 'Selec

WPF Dependency Property for Image source with IValueConverter

I intend to create Usercontrol with boolean dependency property called IsPowerOn, When I change it True the PowerOn image load to Image.source and when I set IsPowerOn to Fals, the PowerOff image load to Image.source. Here is my UserControl: <UserControl x:Class="...UcPower" ... <UserControl.Resources> <local:PowerBoolean2Image x:Key="PowerBoolean2Image"/> </UserControl.Resources> <Grid> <Image x:Name="imgPower" Source="{Binding Source, Converter=

How to draw expander (slider) in wpf

I have a requirement where I need a button which will let the user tap and swipe down/up in order to expand/collapse the control above the button. Something like in this image: How can I achieve it in xaml?

WPF Display same image in two different windows

I have a MainWindow with a datagrid and an image frame. The datagrid contains one image per row. When I select the row, the image (image1) is displayed in a image frame. I want to display that image in another window (WindowPicture) by clicking on a button in MainWindow. I have the following code working fine but when I select a different image, it is updating in the main window but not in the second window: MainWindow XAML Image 1 Image x:Name="image1" Source="{Binding SelectedImage,Mode=Tw

Wpf ListBox virtualization not unloading items

I'm loading a lot of images in a listbox. There was a sensible loading time before i tried to virtualize. Now that i use virtualization only the elements that fall into view are loaded, exactly as i wanted; but they don't seem to unload once they fall outside the view so if i scroll all the way down to the bottom all the items are loaded and i lose the advantage of virtualizing. Before i display any image, my app consumes 140MB, then i display 10 images and my memory usage equals 161MB, if i s

WPF Orienting Expander Header

I'm trying to Orient my head of an expandera and would like to have the expanding button on the right with a check box and text on the left. Currently I have this: <Expander Margin="5" IsExpanded="False" FlowDirection="RightToLeft"> <Expander.Header> <StackPanel Orientation="Horizontal" > <CheckBox IsChecked="{Binding Selected}" ></CheckBox> <TextBlock Text="{Binding FileName}" /> <TextBlock Text="{Binding FileName}" /> <

Wpf Why all the xaml Radio buttons got checked even it is in same group?

In an item control i have dynamically binding the list of Radio button. Each of the radio button having the binding with the 'IsChecked' and 'Group' from View Model. In some certain scenarios from the db level, Ischecked is coming as true for multiple radio buttons in the same group. In that case, all radio button in the same group got checked. it is not unchecking other radio buttons when other radio checked through binding. <ItemsControl DataContext="{Binding}" ItemsSource="{Binding Tab

WPF - Image source in a Style in another assembly

I have a library with some WPF Styles and another application that references this library and it styles, but I'm having a problem with an Image style. I set the Source property in the style with an image in the same library, but when I run my application it returns a XAML Markup error saying it didn't found the image. Library/Styles/MyStyles.xaml (the .png is in Library/Resources/) <Style TargetType="Image" x:Key="MyToolTipImage"> <Style TargetType="Image" x:Key="SmartToolTipImag

Wpf Change Visibility of Stack Panel inside List view on Mouse Hover

Below is my list view <ListView Grid.Column="0" Grid.Row="2" BorderThickness="0" ItemTemplate="{StaticResource ListViewDataTemplate}" x:Name="NewTasks" SelectedItem="{Binding SelectedTask}"/> Data Template For my list view <DataTemplate x:Key="ListViewDataTemplate"> <StackPanel Style="{StaticResource ListViewStackPanel}"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Name="UserActions"> <Image

Blocking launch of WPF Dialog from a different thread

We want to create and launch a modal dialog box over the main window. This process is initiated from a different thread - for some reason. This different thread calls the execute method - and must be blocked until the dialog box closes. The question is - how? On this code the execute won't be blocked. The Join() call also does not work as expected. public void Execute() { Thread newWindowThread = new Thread(new ThreadStart(ThreadStartingPoint)); newWindowThread.SetApartmentState(Apartme

Wpf How do I change the skin of the ComboBox?

My English skill is poor because I'm not a native English speaker. I hope you to understand. I trying to create the style of control to support the skin. Recently, I created a style for ComboBox as shown below. <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}"> <Setter Property="Background" Value="Transparent" /> <Setter Property="Foreground" Value="{DynamicResource ActiveTextBrush}"/> <Style.Triggers> <Trigger P

  1    2   3   4   5   6  ... 下一页 最后一页 共 240 页