WPF- How to set wpf datagrid row validation errors to a separate textblock?

In WPF i have a DataDrid with different validations. so far i used ToolTip in the DataGrid to show the error validation.

Now the client asked to show the validation error in on different TextBlock/Label in the page- how do i do that? How do i use the: (Validation.Errors)[0].ErrorContent outside the DataGrid?

thats what i had till now:

<DataGrid.RowValidationErrorTemplate> <ControlTemplate> <Grid Margin="0,-2,0,-2" ToolTip="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}},Path=(Validation.Errors)[0].ErrorContent}"> <Ellipse StrokeThickness="0" Fill="Red" Width="{TemplateBinding FontSize}" Height="{TemplateBinding FontSize}" /> <TextBlock Text="!" FontSize="{TemplateBinding FontSize}" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </ControlTemplate> </DataGrid.RowValidationErrorTemplate>

Category:c# Views:97 Time:2019-03-21

Related post

  • WPF DataGrid row validation error count 2010-04-18

    I'm currently facing the problem, that I import an Excel file to a DataGrid. This works pretty fine, but after importing the table, I need to know how many rows are invalid. I have applied several validation rules for the different datatypes, and I h

  • WPF: Detect row validation errors in C# code 2011-08-19

    I want to achieve a pretty simple task, but none of the solutions here on SO or otherwise found have helped me so far: I have a WPF DataGrid, which is bound to a typed data set. When I click the OK button in my window, I want to detect whether there

  • How to set WPF window's startup ClientSize? 2009-07-04

    I want to set my WPF window's initial client size. I'm not seeing a straightforward way to do this. Specifically, when my window opens, I want it to be sized just big enough for its contents to fit without needing scrollbars. But after it's shown, I

  • How to find visible DataGrid rows in Silverlight? 2011-02-22

    How to find visible DataGrid rows in Silverlight? --------------Solutions------------- I'm not sure what you mean by Visible DataGridRows but you could get all DataGridRows that are generated at the moment by finding them in the Visual Tree. This wil

  • How To Set Excel Default Row Height in Apache POI 2012-02-08

    I'm using Apache POI 3.7 with Spring MVC 3.1. How to set excel default row height in apache POI? I've tried sheet.setDefaultRowHeight((short) 100) and sheet.setDefaultRowHeightInPoints(100) but that doesn't work. Any suggestion for this problem? Than

  • WPF DataGrid: set focus on a specific cell after a row validation error 2011-07-25

    I have a WPF DataGrid with RowValidationRules. I would like to set the focus or begin editing a specific cell in case a validation fails. For example, if the value in a cell has be lower than the value in another cell and the user does not respect th

  • WPF : How to set a Dialog position to show at the center of the application? 2010-11-29

    How to set Dialog's position that came from .ShowDialog(); to show at the center of the mainWindows. This is the way I try to set position. private void Window_Loaded(object sender, RoutedEventArgs e) { PresentationSource source = PresentationSource.

  • How to set WPF Combobox SelectedValue by code behind based on the custom class? 2012-01-18

    I need to select custom item under WPF Combobox by code behind. For example: "Spanish" UILanguages languages = new UILanguages(); languages.Add( new UILanguage { Culture = "en", SpecCulture = "en-US", EnglishName = "English" }); languages.Add( new UI

  • WPF: How to set background of TabItem? 2011-06-08

    How to set the background of TabItem? I tried the following code: <TabControl> <TabItem Header="Test" Background="Blue" Foreground="Red" /> </TabControl> Foreground works, but Background does not work. Any ideas? Thanks ------------

  • MVVM and Conversion Errors in WPF - Combining ConvertBack Exceptions from View with Validation Errors from Model? 2011-04-06

    I am developing a WPF application using the MVVM pattern as described by Josh Smith in the article at http://msdn.microsoft.com/en-us/magazine/dd419663.aspx. I can't figure out a good way of reacting to Convert Back errors (for example when a user ty

  • How to set a default row for a query that returns no rows? 2008-11-12

    I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value. Edit: This would be SQL Server. --------------Solutions----

  • WPF DataBinding: Nullable Int still gets a validation error? 2010-07-21

    I have a textbox databound to a nullable int through code. If I erase the data from the textbox it gives me a validation error (red border around it). Here is my binding code: ZipBinding = new Binding("Zip"); ZipBinding.Source = Address; zipTextBox.S

  • How to get the DataGrid row data in Textboxs 2011-06-26

    How do I get the DataGrid row data while selecting a DataGrid. For example, while selecting a row in a DataGrid , I want to show that field data in concern TextBoxes. Please see the code snippet below <asp:TextBox ID="tbCode" runat="server" TabInd

  • How to programmatically iterate datagrid rows? 2008-08-08

    I'm suddenly back to WinForms, after years of web development, and am having trouble with something that should be simple. I have an ArrayList of business objects bound to a Windows Forms DataGrid. I'd like the user to be able to edit the cells, and

  • How to set all matching rows property isDelete to False? 2010-01-04

    Using Hql or criteria, how can I update many rows and set a property to false? ie. SQL would be: UPDATE UserOrders SET isDeleted = 0 -- (boolean false) WHERE uID = 234 --------------Solutions------------- If you do not use the business object in any

  • SWT table: how to set/get "focused" row 2012-01-13

    On Windows and Linux, when holding down the Ctrl key one can move up and down using the caret keys without changing the selection. The table shows some visual feedback. I've played with an SWT snippet which uses TableCursor but it seems half-baked, b

  • How to set the order of validation messages? 2012-02-03

    We're using the "Error Messages" XPages (native) control to show the validation errors to user. It works. The validation is done by setting the field as required and entering the field error message. Nothing special. Now the requirement is to set the

  • Python + GTK: How to set a selected row on gtk.treeview 2012-03-30

    I'm trying to do a keyboard command. When I insert S+some_number+Return I need call a function that will see this number on a column on Gtk.Treeview and set that row has selected. How can I do that? --------------Solutions------------- <treeview

  • How to set and keep a validation rule on all cells in a column of a Spreadsheet 2012-12-06

    Is there a way to set and keep a validation rule on every cell in a spreadsheets row, even when user inserts or appends a new row? --------------Solutions------------- Even i had the same question but at last found a solution this might be option for

  • How to set a specific row height in Word 2007 2013-09-01

    I am have created a table in Word 2007 but cant seem to figure out how to set the row height to an exact size. I figured out how to set the width but not the height I am inserting photos in the cell and do not want to have to re-size every photo but

  • How to set errorContainer in jQuery validation dynamically? 2010-01-12

    Can I dynamically set errorContainer in jQuery validation, which means showing different error container base on the button clicked. This is what I am trying to do, but seems doesn't work: $('#b1').click(function(evt) { $('#form1').validate().resetFo

  • How to set grid height row in extjs 2011-10-12

    In my code I'm using four grids, I've set the row height in css like this: .x-grid3-row td {line-height: 50px;} and it sets the rows of all my grids. So I need to set the height row of one of those grids. --------------Solutions------------- Based on

  • How can I display CakePHP input validation errors in a different spot the default? 2010-06-07

    Let's say I have field that looks like this in the view: <li class="bigfield"> <?php echo $form->input('phone', array( 'placeholder' => 'Phone', 'label' => false, 'between' => '<br />' )); ?> </li> If I have a vali

  • How to disable the display of validation errors in view (Cakephp) 2011-06-05

    I have a view which is containing 5 forms submitting separately but to the same model. The aim of this is allow the user to fill all the forms in the same page and be able to quickly compare the values he puts in for each form. Each form has most of

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.179 (s). 12 q(s)