Search Results

Search found 10936 results on 438 pages for 'wpf controls'.

Page 1/438 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • WPF 4.0 Custom panel won't show dynamically added controls in VS 2010 Designer

    - by Matt Ruwe
    I have a custom panel control that I'm trying to dynamically add controls within. When I run the application the static and dynamically added controls show up perfectly, but the dynamic controls do not appear within the visual studio designer. Only the controls placed declaratively in the XAML appear. I'm currently adding the dynamic control in the CreateUIElementCollection override, but I've also tried this in the constructor without success. Public Class CustomPanel1 Inherits Panel Public Sub New() End Sub Protected Overrides Function MeasureOverride(ByVal availableSize As System.Windows.Size) As System.Windows.Size Dim returnValue As New Size(0, 0) For Each child As UIElement In Children child.Measure(availableSize) returnValue.Width = Math.Max(returnValue.Width, child.DesiredSize.Width) returnValue.Height = Math.Max(returnValue.Height, child.DesiredSize.Height) Next returnValue.Width = If(Double.IsPositiveInfinity(availableSize.Width), returnValue.Width, availableSize.Width) returnValue.Height = If(Double.IsPositiveInfinity(availableSize.Height), returnValue.Height, availableSize.Height) Return returnValue End Function Protected Overrides Function ArrangeOverride(ByVal finalSize As System.Windows.Size) As System.Windows.Size Dim currentHeight As Integer For Each child As UIElement In Children child.Arrange(New Rect(0, currentHeight, child.DesiredSize.Width, child.DesiredSize.Height)) currentHeight += child.DesiredSize.Height Next Return finalSize End Function Protected Overrides Function CreateUIElementCollection(ByVal logicalParent As System.Windows.FrameworkElement) As System.Windows.Controls.UIElementCollection Dim returnValue As UIElementCollection = MyBase.CreateUIElementCollection(logicalParent) returnValue.Add(New TextBlock With {.Text = "Hello, World!"}) Return returnValue End Function Protected Overrides Sub OnPropertyChanged(ByVal e As System.Windows.DependencyPropertyChangedEventArgs) MyBase.OnPropertyChanged(e) End Sub End Class And my usage of this custom panel <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustomPanel" Title="MainWindow" Height="364" Width="434"> <local:CustomPanel1> <CheckBox /> <RadioButton /> </local:CustomPanel1> </Window>

    Read the article

  • A WPF Image/Text Button

    - by psheriff
    Some of our customers are asking us to give them a Windows 8 look and feel for their applications. This includes things like buttons, tiles, application bars, and other features. In this blog post I will describe how to create a button that looks similar to those you will find in a Windows 8 application bar. In Figure 1 you can see two different kinds of buttons. In the top row is a WPF button where the content of the button includes a Border, an Image and a TextBlock. In the bottom row are four...(read more)

    Read the article

  • Export data to Excel from Silverlight/WPF DataGrid

    - by outcoldman
    Data export from DataGrid to Excel is very common task, and it can be solved with different ways, and chosen way depend on kind of app which you are design. If you are developing app for enterprise, and it will be installed on several computes, then you can to advance a claim (system requirements) with which your app will be work for client. Or customer will advance system requirements on which your app should work. In this case you can use COM for export (use infrastructure of Excel or OpenOffice). This approach will give you much more flexibility and give you possibility to use all features of Excel app. About this approach I’ll speak below. Other way – your app is for personal use, it can be installed on any home computer, in this case it is not good to ask user to install MS Office or OpenOffice just for using your app. In this way you can use foreign tools for export, or export to xml/html format which MS Office can read (this approach used by JIRA). But in this case will be more difficult to satisfy user tasks, like create document with landscape rotation and with defined fields for printing. At this article I'll show you how to work with Excel object from .NET 4 and Silverlight 4 with dynamic objects and give you an approach which allow you to export data from DataGrid Silverlight and WPF controls. Read more...

    Read the article

  • Where is the WPF Numeric UpDown control?

    - by AngryHacker
    Getting into the first serious WPF project. It seems like there are a lot of basic controls flat out missing. Specifically, I am looking for the Numeric UpDown control. Was there an out of band release that I missed? Really don't feel like writing my own control. I do not want to use the WindowsFormHost and plop a WinForm ctl on it. I want it to be fully WPF without any legacy junk. Thanks

    Read the article

  • Winform custom control in WPF

    - by Erika
    Hi, I'm inserting a custom winform control in a WPF/ XAML window, however i'm realising that the sizing seems to be very different, what i designed in winform to be 730pixels wide for instance, when placed via a WindowsFormsHost, in a container 730pixels (or at least i think they're pixels..) wide, the control looks much larger and doesnt fit in the host and results in clipping from the right and bottom. Would anyone know how to make these sizes match or something? I'm really at a loss and its very difficult to fix a custom control to make it look as it should off hand on WPF! Please help!

    Read the article

  • WPF Login Screen

    - by Asim Sajjad
    I have search on google about the login screens which are design in WPF , as I have to using one of the best login screen for my application, Is the any good login screen avaialble so that I can see them and choose one of them, I am having no idean about the good design of the login screen. Please help me, thanks in advance

    Read the article

  • WPF Dialog Box Property Value Editor access source control

    - by Cicik
    Hello, I have User control in WPF with dependency property DEP1 on which i set value by DialogPropertyValueEditor(code below): Public Class OPCItemDialogPropertyValueEditor Inherits DialogPropertyValueEditor Private res As New EditorResources() Public Sub New() Me.InlineEditorTemplate = TryCast(res("OPCItemInlineEditorTemplate"), DataTemplate) End Sub Public Overrides Sub ShowDialog(ByVal propertyValue As PropertyValue, ByVal commandSource As IInputElement) Dim window As New MyWindowToSetProperty(SomeParameter, "STRING Value Of ANother Property In control") If window.ShowDialog() Then propertyValue.Value = window.ChoosedOPCItem End If End Sub End Class I need to set value of property of my control as parameter("STRING Value Of ANother Property In control") for window from i set value to property DEP1 Thanks

    Read the article

  • WPF Dialog Box Property Value Editor access source(parent) control

    - by Cicik
    Hello, I have User control in WPF with dependency property DEP1 on which i set value by DialogPropertyValueEditor(code below): Public Class OPCItemDialogPropertyValueEditor Inherits DialogPropertyValueEditor Private res As New EditorResources() Public Sub New() Me.InlineEditorTemplate = TryCast(res("OPCItemInlineEditorTemplate"), DataTemplate) End Sub Public Overrides Sub ShowDialog(ByVal propertyValue As PropertyValue, ByVal commandSource As IInputElement) Dim window As New MyWindowToSetProperty(SomeParameter, "STRING Value Of ANother Property In control") If window.ShowDialog() Then propertyValue.Value = window.ChoosedOPCItem End If End Sub End Class I need to set value of property of my control as parameter("STRING Value Of ANother Property In control") for window from i set value to property DEP1 Thanks

    Read the article

  • [WPF] Control focus styling

    - by Prashant
    Hey guys, in above image you would notice that, doted rectangle indicating ComboBox is focused But the problem is it exceeding the text area of ComboBox... how do I align it with text area WPF Style? Thanks

    Read the article

  • DataTrigger to make WPF Button inactive until TextBox has value

    - by JohnB
    I want the Button control's property to be IsEnabled="False" until a value is entered into a TextBox in the Window. Code so far: <Button Content="Click Me" Name="ClickMe" VerticalAlignment="Top" Click="ClickMe_Click"> <Button.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=textBox, Path=Length}" <!-- or even: Binding="{Binding Path=textBox.Length}" --> Value="0"> <Setter Property="Button.IsEnabled" Value="false" /> </DataTrigger> </Style.Triggers> </Style> </Button.Style> </Button> Also, is it possible to have this Button control's IsEnabled property be based on 3 different TextBox controls all having values?

    Read the article

  • WPF DataGrid binding to UserControl

    - by Trindaz
    I have a DataGrid with one column using a UserControl via a styled DataGridTemplateColumn. I can't seem to get the UserControl to 'see' the object that is in it's containing DataGridCell though. What kind of bindings can I create on the TextBox in my UserControl so that it can look up and see that object?! My UserControl and TemplateColumn Style are defined as: <Window.Resources> <local:UCTest x:Key="UCTest" /> <Style x:Key="TestStyle" TargetType="{x:Type WpfToolkit:DataGridCell}"> <Style.Setters> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WpfToolkit:DataGridCell}"> <Grid Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource drc}, Path=DataContext}"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <local:UCTest /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style.Setters> </Style> </Window.Resources> and my sample DataGrid is defined as: <WpfToolkit:DataGrid Name="dgSampleData" ItemsSource="{Binding}" AutoGenerateColumns="True" Margin="0,75,0,0"> <WpfToolkit:DataGrid.Columns> <WpfToolkit:DataGridTemplateColumn Header="Col2" CellStyle="{StaticResource TestStyle}" /> </WpfToolkit:DataGrid.Columns> </WpfToolkit:DataGrid> and my User Control is defined in a separate file as: <UserControl x:Class="UCTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:WpfApplication1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="104" Height="51"> <UserControl.Resources> <local:DataRowConverter x:Key="drc" /> </UserControl.Resources> <Grid> <TextBox Margin="12,12,-155,16" Name="TextBox1" Text="" /> </Grid> EDIT: My implementation of TestClass, which has the Test Property, which I want UCTest.TextBox1 to bind do: Public Class TestClass Private _Test As String = "Hello World Property!" Public Property Test() As String Get Return _Test End Get Set(ByVal value As String) _Test = value End Set End Property End Class Thanks in advance!

    Read the article

  • WPF binding to current class property

    - by AnD
    Hello, I have a problem that i cant solve :( I have a user control (xaml file and cs file) in xaml it's like: <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Demo.CtrlContent" x:Name="UserControl" d:DesignWidth="598.333" d:DesignHeight="179.133" xmlns:Demo="clr-namespace:Demo" > <UserControl.Resources> <Storyboard x:Key="SBSmall"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(FrameworkElement.Width)"> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="I WANT TO BIND VALUE HERE"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <Border BorderBrush="#FFC2C0C1" CornerRadius="3,3,3,3" BorderThickness="1,1,1,1" RenderTransformOrigin="0.5,0.5" x:Name="border" Margin="1,3,1,3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300"> and .cs file: public partial class CtrlContent { private mindef W { get { return (mindef) Window.GetWindow(this); } } public double MedWidth { // I WANT BIND THIS VALUE GO TO STORYBOARD VALUE IN XAML ABOVE get { double actualW; if(W == null) actualW = SystemParameters.PrimaryScreenWidth; else actualW = W.WrapMain.ActualWidth; return actualW - border.Margin.Left - border.Margin.Right; } } public double SmlWidth { get { return MedWidth / 2; } } public CtrlContent () { this.InitializeComponent(); } public CtrlContent (Content content) { this.InitializeComponent(); Document = content; } } in my .cs file there's a property called MedWidth, and in XAML file there's a storyboard called: SBSmall I want to bind my storyboard value to my property in class ctrlcontent. *the idea is, the storyboard is an animation to resize the control to a certain width depends on its parent container (the width is dynamic) anybody? please :) thanks!

    Read the article

  • WPF trigger on datagrid to hide/show columns according to bindings

    - by Renan
    I have a data grid like this: <DataGrid AutoGenerateColumns="False" CanUserDeleteRows="True" HorizontalScrollBarVisibility="Hidden" Margin="10,10,10,10" VerticalScrollBarVisibility="Visible" CanUserAddRows="False" ItemsSource="{Binding ListGestores}" ToolTip="Selecione uma linha e pressione DELETE para remover uma unidade."> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding TB_UNIDADE.DS_NOME_UNIDADE}" CanUserResize="False" Header="Setor" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_UNIDADE.TB_UNIDADE2.DS_NOME_UNIDADE}" CanUserResize="False" Header="Unidade" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_CONTATOS.DS_NOME}" CanUserResize="False" Header="Gestor" IsReadOnly="True" /> </DataGrid.Columns> </DataGrid> The problem is that i need to verify if the 2 column binding is null, and if it is null, i need to Hide it, and Change the Header of the column 1. I know that i can do that with Triggers, but how exactly??? I started with: <DataGrid.Triggers> <DataTrigger Binding="{Binding TB_UNIDADE.TB_UNIDADE2}" Value="{x:Null}"> <Setter Property="" Value="" /> </DataTrigger> </DataGrid.Triggers> But i don't know what setter or whatever to put ! Help me =]

    Read the article

  • Binding the position and size of a UserControl inside a Canvas in WPF

    - by John
    Hi. We have dynamically created (i.e. during runtime, via code-behind) UserControls inside a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable and draggable UserControls to a ObservableCollection<. How would we achieve this if the Usercontrol is contained in a DataTemplate which in turn is used by a ListBox whose DataContext is set to the collection we want to bind to? In other words, how do we bind a control's position and size that doesn't exist in XAML, but in code only (because it's created by clicking and dragging the mouse)? Notice that the collection can be empty or not empty, meaning that the size and position stores in a collection item must be correctly bound to so that the UserControl can be sized and positioned correctly in the Canvas - via DataBinding. Is this possible?

    Read the article

  • How to bind a datatable to a wpf editable combobox: selectedItem showing System.Data.DataRowView

    - by black sensei
    Hello Good People!! I bound a datatable to a combobox and defined a dataTemplate in the itemTemplate.i can see desired values in the combobox dropdown list,what i see in the selectedItem is System.Data.DataRowView here are my codes: <ComboBox Margin="128,139,123,0" Name="cmbEmail" Height="23" VerticalAlignment="Top" TabIndex="1" ToolTip="enter the email you signed up with here" IsEditable="True" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=username}"/> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> The code behind is so : if (con != null) { con.Open(); //users table has columns id | username | pass SQLiteCommand cmd = new SQLiteCommand("select * from users", con); SQLiteDataAdapter da = new SQLiteDataAdapter(cmd); userdt = new DataTable("users"); da.Fill(userdt); cmbEmail.DataContext = userdt; } I've been looking for something like SelectedValueTemplate or SelectedItemTemplate to do the same kind of data templating but i found none. I'll like to ask if i'm doing something wrong or it's a known issue for combobox binding? if something is wrong in my code please point me to the right direction. thanks for reading this

    Read the article

  • WPF Styles and Tooltips Question

    - by A.R.
    I have a style that I am using to make dynamic tooltips on certain text boxes like so. <Style TargetType="{x:Type TextBox}"> <Setter Property="MinWidth" Value="100"/> <Style.Triggers> <Trigger Property="Validation.HasError" Value="True"> <!-- item of interest --> <Setter Property="ToolTip"> <Setter.Value> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding RelativeSource="{RelativeSource Self}" Path="Tag"/> </MultiBinding> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> This works very well, but if I want to use a more complex tooltip I can't figure out how to bind to 'Tag' anymore for the converter value. For example; ... <Setter Property="ToolTip"> <Setter.Value> <StackPanel> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <!-- item of interest --> <Binding RelativeSource=" what goes here?? "/> </MultiBinding> </TextBlock.Text> </TextBlock> <Image/> </StackPanel> </Setter.Value> </Setter> ... I have tried several flavors of 'FindAncestor' and what not for the relative source, but I can't get anything to work. Any ideas?? UPDATE: 12-29-2010 : Here is the correct code, answer provided by our friend Goblin below. Works perfectly! ... <Setter Property="ToolTip"> <Setter.Value> <!-- Item of interest --> <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}"> <StackPanel> <Image/> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding Path="Tag"/> </MultiBinding> </TextBlock.Text> </TextBlock> </StackPanel> </ToolTip> </Setter.Value> </Setter> ...

    Read the article

  • Question on MVVM pattern on WPF ?

    - by Ashish Ashu
    I have a user control let say UC1 . This user control have viewmodel UC1_vm. In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm). The data points property inside the view model change with different condition. The generation of data points is written in the View Model. I want to bind the data points property in the view model to the draw curve logic inside the User control (view). I want whenever the data point property is changed in the view model , the canvas calls the draw curve method. Can I set the set any property of canvas which when changed it calls the on paint logic auto matically? Please suggest me the approach of implementing this scenario!!

    Read the article

  • WPF Dockable Windows Like iGoogle

    - by Anon
    I'm looking for a dockable windows/panel control in the style of iGoogle. All of the ones I have found so far all have a fixed length on the height of your window/panel but I want to be able to have windows of varying length like iGoogle. The best I have found so far has been a control libarary called BlackLight which does not have the feature explained above.

    Read the article

  • Books about Advanced WPF control building

    - by Carlo
    Hello. I'm really interested in learning really advanced features of WPF to learn how to create advanced controls, but apparently I'm running out of resources, and possibly, imagination. I have these 4 books: WPF Control Development Unleashed Experiences Pro WPF 2008 Presentation Professionals Programming WPF Chris Sells WPF in Action Visual Studio 2008 One finished, two other half way, the other one just started. I sort of expected more from the "WPF Control Development Unleashed" one. Anyway, do you know any more books about advanced WPF features, and control building? Or even about how WPF works internally. Let me know what are your favorite WPF books, maybe I've overlooked some of them. Thanks!

    Read the article

  • Windows Presentation Foundation 4.5 Cookbook Review

    - by Ricardo Peres
    As promised, here’s my review of Windows Presentation Foundation 4.5 Cookbook, that Packt Publishing kindly made available to me. It is an introductory book, targeted at WPF newcomers or users with few experience, following the typical recipes or cookbook style. Like all Packt Publishing books on development, each recipe comes with sample code that is self-sufficient for understanding the concepts it tries to illustrate. It starts on chapter 1 by introducing the most important concepts, the XAML language itself, what can be declared in XAML and how to do it, what are dependency and attached properties as well as markup extensions and events, which should give readers a most required introduction to how WPF works and how to do basic stuff. It moves on to resources on chapter 2, which also makes since, since it’s such an important concept in WPF. Next, chapter 3, come the panels used for laying controls on the screen, all of the out of the box panels are described with typical use cases. Controls come next in chapter 4; the difference between elements and controls is introduced, as well as content controls, headered controls and items controls, and all standard controls are introduced. The book shows how to change the way they look by using templates. The next chapter, 5, talks about top level windows and the WPF application object: how to access startup arguments, how to set the main window, using standard dialogs and there’s even a sample on how to have a irregularly-shaped window. This is one of the most important concepts in WPF: data binding, which is the theme for the following chapter, 6. All common scenarios are introduced, the binding modes, directions, triggers, etc. It talks about the INotifyPropertyChanged interface and how to use it for notifying data binding subscribers of changes in data sources. Data templates and selectors are also covered, as are value converters and data triggers. Examples include master-detail and sorting, grouping and filtering collections and binding trees and grids. Last it covers validation rules and error templates. Chapter 7 talks about the current trend in WPF development, the Model View View-Model (MVVM) framework. This is a well known pattern for connecting things interface to actions, and it is explained competently. A typical implementation is presented which also presents the command pattern used throughout WPF. A complete application using MVVM is presented from start to finish, including typical features such as undo. Style and layout is covered on chapter 8. Why/how to use styles, applying them automatically,  using the many types of triggers to change styles automatically, using Expression Blend behaviors and templates are all covered. Next chapter, 9, is about graphics and animations programming. It explains how to create shapes, transform common UI elements, apply special effects and perform simple animations. The following chapter, 10, is about creating custom controls, either by deriving from UserControl or from an existing control or framework element class, applying custom templates for changing the way the control looks. One useful example is a custom layout panel that arranges its children along a circumference. The final chapter, 11, is about multi-threading programming and how one can integrate it with WPF. Includes how to invoke methods and properties on WPF classes from threads other than the main UI, using background tasks and timers and even using the new C# 5.0 asynchronous operations. It’s an interesting book, like I said, mostly for newcomers. It provides a competent introduction to WPF, with examples that cover the most common scenarios and also give directions to more complex ones. I recommend it to everyone wishing to learn WPF.

    Read the article

  • Need to replace 3rd party WinForm controls, what's the closet WPF equivalent?

    - by Refracted Paladin
    I am tired of Windows Forms...I just am. I am not trying to start a debate on it I am just bored with it. Unfortunately we have become dependent on 4 controls in DevExpress XtraEditors. I have had nothing but difficulties with them and I want to move on. What I need now is what the closet replacement would be for the 4 controls I am using. Here they are: LookUpEdit - this is a dropdown that filters the dropdown list as you type. MemoExEdit - this is a textbox that 'pops up' a bigger area when it has focus CheckedComboBoxEdit - this is a dropdown of checkboxes. CheckedListBoxControl - this is a nicely columned list box of checkboxes This is a LOB app that has tons of data entry. In reality, the first two are nice but not essential. The second two are essential in that I would either need to replicate the functionality or change the way the users are interacting with that particular data. I am looking for help in replicating these in a WPF environment with existing controls(codeplex etc) or in straight XAML. Any code or direction would be greatly appreciated but mostly I am hoping to avoid any commercial 3rd party WPF and would instead like to focus on building them myself(but I need direction) or using Codeplex

    Read the article

  • Reset the controls within asp placeholder

    - by alaa9jo
    I use placeholders very much in many projects,but in one of the projects I was asked to reset the controls within a specific placeholder to their original state after the user has finished from inserting his/her data. As everyone of us know,to keep the controls within a placeholder from disappearing after postbacks you have to recreate them,we add such a code in i.e. page_load,the controls will be recreated and their values will be loaded from viewstate (for some of them like textbox,checkboxs,..etc) automatically,that placeholder contains only textboxs so what I need is to block/ loading/clear that viewstate after inserting the data. First thought: Customizing placeholder I thought about it and tried overriding many methods but no success at all...maybe I'm missing something not sure. Second thought: recreate the controls 2 times: In page_load,I recreate the controls within that placeholder then in button click (the button that saves user's data) I recreate them once more and it worked! I just thought of sharing my experience in that case with everyone in case anyone needed it,any better suggestion(s) is welcomed.

    Read the article

  • Reducing WPF binding boilerplate with styles - updating the bindings themselves via styling?

    - by Eamon Nerbonne
    I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I'd like to set based on the target of the binding - pretty normal stuff. However, I'd also like to set properties of the binding itself in the style to avoid repetitiveness. For example: <TextBox Style="{StaticResource myStyle}"> <TextBox.Text> <Binding Path="..." Source="..." ValidatesOnDataErrors="True" ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged"> </Binding> </TextBox.Text> </TextBox> Now, is there any way to use styling - or some other technique to write the previous example somewhat like this: <TextBox Style="{StaticResource myStyle}" Text="{Binding Source=... Path=...}/> That is, is there any way to set all bindings that match a particular selection (here, on controls with the myStyle style) to validate data and to use a particular update trigger? Is it possible to template or style bindings themselves? Clearly, the second syntax is much, much shorter and more readable, and I'd love to be able to get rid of other similar boilerplate to keep my UI code comprehensible to myself :-).

    Read the article

  • WPF: Is it possible to add or modify bindings via styles or something similar?

    - by Eamon Nerbonne
    I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I'd like to set based on the target of the binding - pretty normal stuff. However, I'd also like to set properties of the binding itself in the style to avoid repetitiveness. For example: <TextBox Style="{StaticResource myStyle}"> <TextBox.Text> <Binding Path="..." Source="..." ValidatesOnDataErrors="True" ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged"> </Binding> </TextBox.Text> </TextBox> Now, is there any way to use styling - or some other technique to write the previous example somewhat like this: <TextBox Style="{StaticResource myStyle}" Text="{Binding Source=... Path=...}/> That is, is there any way to set all bindings that match a particular selection (here, on controls with the myStyle style) to validate data and to use a particular update trigger? Is it possible to template or style bindings themselves? Alternatively, is it possible to add the binding in the style itself? Clearly, the second syntax is much, much shorter and more readable, and I'd love to be able to get rid of other similar boilerplate to keep my UI code comprehensible to myself :-).

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >