Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all 18858 articles
Browse latest View live

Do not change property on two events in Visual State Manager

$
0
0

I am working on the style of a dropdown and all was going well until i realized that when i set the Visual state manager : Mouse over it would also change my item to the mouseover color....then when i moved mouse away from it, it went back to the color it was before it was "selected". Its still the selected item but it wont stay.

What i want to do is have it not change the selected item color on mouse over. Any ideas?

<VisualStateManager.VisualStateGroups><VisualStateGroup x:Name="CommonStates"><VisualState x:Name="Normal" /><VisualState x:Name="MouseOver"><Storyboard>                                                    <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
                                                Storyboard.TargetProperty="(Panel.Background).
                    (SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{StaticResource grey-Primary200}" /></ColorAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup><VisualStateGroup x:Name="SelectionStates"><VisualState x:Name="Unselected" /><VisualState x:Name="Selected"><Storyboard>                               <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"           Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"><EasingColorKeyFrame KeyTime="0" Value="{StaticResource teal-Primary500}" /></ColorAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup>                           </VisualStateManager.VisualStateGroups>



VS2012 WPF Designer: d:DataContext - number of generic arguments provided doesn't equal the arity...

$
0
0

When using a class as a d:DesignInstance that exposes aKeyedCollection<TKey, TItem>, the XAML designer complains with the following warning:

The number of generic arguments provided doesn't equal the arity of the generic type definition.
Parameter name: instantiation

The problem can be reproduced with the following simple program:

<Window x:Class="Test.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:local="clr-namespace:Test"
        mc:Ignorable="d"
        d:DataContext="{d:DesignInstance local:MyClass}"/>
namespace Test{publicpartialclassMainWindow:Window{publicMainWindow(){InitializeComponent();}}publicclassMyClass{publicKeyedCollection<string,object>SettingsModule{ get;privateset;}}}

I'm unable to provide design time shape with any class that exposes a KeyedCollection.

Any ideas what is going on here?

Thanks.




Entity Framework MVVM Walk Through 1 - getting error when connecting to database

$
0
0

I'm going through this tutorial:
WPF: Entity Framework MVVM Walk Through 1.
http://social.technet.microsoft.com/wiki/contents/articles/28209.wpf-entity-framework-mvvm-walk-through-1.aspx

But I'm getting stuck on this step:
"As the SalesSystem database is new you will need to choose New Connection and connect to wherever you set the database up."

 So the steps I'm doing is:
1) In Solution Explorer, right click your project, Add new Item, choose Data and ADO.Net Entity Data Model. 
2) EF Designer from database will be highlighted and it's what you want, so click Next. 
3) As the SalesSystem database is new you will need to choose New Connection and connect to wherever you set the database up. 
4) Then there are two options:
Microsoft SQL Server
Microsoft SQL Server Database File (since I'm using SQL Express this seems to be the best option).

So then I press continue and locate the database named "SalesSystem.mdf". Then when click "Test Connection" I get this error message:

---------------------------------------------------------------------------------
Microsoft Visual Studio Express 2013 for Windows Desktop
---------------------------------------------------------------------------------
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\SalesSystem.mdf". Operating system error 5: "5(Access is denied.)".

An attempt to attach an auto-named database for file C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\SalesSystem.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

---------------------------------------------------------------------------------
END Error Message
---------------------------------------------------------------------------------

What could be the reason for this error? 

Listbox, public class, extracting multi selected items?

$
0
0

Hi all,

I have a listbox that gets its data using a public class. I return a list of the public class and assign it to the itemsource of the listbox. I can select multiple items from the listbox. I have no problem getting the value for a single selected item but I can not figure how to get the "rootSymbol" from multiple selected items.

I'm trying to get all the selected "rootSymbol" into the "symbolsToRemove" (string) list.

Can someone point me in the right direction please.

Thanks

The public class:

public class callPutItems
{
  public string issueDesc { get; set; }
  public string rootSymbol { get; set; }
  public string symbol { get; set; }

  public override string ToString()
  {
    return this.issueDesc;
  }
}

The code to extract single and multiple values:

callPutItems singleSelected = new callPutItems();
List<callPutItems> multiSelected;

List<string> symbolsToRemove = new List<string>();


if (callsListbox.SelectedItems.Count == 1)
{
  singleSelected = (callPutItems)callsListbox.SelectedItem;
  symbolsToRemove.Add(singleSelected.rootSymbol);

}
else
{
  multiSelected = new List<callPutItems>(callsListbox.SelectedItems.Count);

  //multiSelected.AddRange(List<callPutItems>callsListbox.SelectedItems);  NO GOOD!

  //foreach (var item in callsListbox.SelectedItems)  NO GOOD EITHER!
  //{
  //  symbolsToRemove.Add(item.rootSymbol);
  //}
}

Thanks again.

 


How do I eliminate the space placed between paragraphs in a RichTextBox?

$
0
0
How do I eliminate the space placed between paragraphs in a RichTextBox?

gobjParagaph.Inlines.Add(new Run(st));
gobjFlowDoc.Blocks.Add(gobjParagaph);
gRTbx.Document = gobjFlowDoc;

After displaying information in a RichTextBox programmatically, the customer edits the information. However, when the customer hits "Enter" button, the cursor jumps down two spaces.


bhs67

How to view all designer resource warnings?

$
0
0
We have hundreds of dialogs in XAML.  
When we make a global resource change, 
it can break the resource links in the XAML.

When we open the XAML view in VisualStudio 2012's designer, 
it show these broken links as resource warnings:

"Warning 43 The resource "XamSliderNumericThumbStyle" could not be resolved."

Is there some way to view all of the designer warnings without manually opening up each dialog?

Debugger exception on WPF loading

$
0
0

Hello,

    I am looking for a little help with this.  I have a WPF browser form that I am trying to load.  I run the debugger, but when it gets to the page I get the following:

An exception of type 'System.Security.SecurityException' occurred in System.Data.dll but was not handled in user code

Additional information: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

If there is a handler for this exception, the program may be safely continued.

The call stack for that shows this:

> HomeInventoryWebForms.exe!HomeInventoryWebForms.frmMoviesAdd.dgMTVAddFormat_Window_Loaded(object sender, System.Windows.RoutedEventArgs e) Line 70 C#

So here is the code behind the form:

public frmMoviesAdd()
            {
            InitializeComponent();
            this.Loaded += dgMTVAddFormat_Window_Loaded;
            this.Loaded += dgMTVAddGenre_Window_Loaded;
            }
private void dgMTVAddFormat_Window_Loaded(object sender, RoutedEventArgs e)
            {
            FormatDataClassesDataContext data = new FormatDataClassesDataContext();
            List<tblFormat> Format = (from FormatName in data.tblFormats select FormatName).ToList();
            dgMTVAddFormat.ItemsSource = Format;
            }

This is backed up with LINQ to SQL class that was auto generated:

	[global::System.Data.Linq.Mapping.DatabaseAttribute(Name="HomeInventory")]
	public partial class FormatDataClassesDataContext : System.Data.Linq.DataContext
	{

		private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

    #region Extensibility Method Definitions
    partial void OnCreated();
    partial void InserttblFormat(tblFormat instance);
    partial void UpdatetblFormat(tblFormat instance);
    partial void DeletetblFormat(tblFormat instance);
    #endregion

		public FormatDataClassesDataContext() :
				base(global::HomeInventoryWebForms.Properties.Settings.Default.HomeInventoryConnectionString, mappingSource)
		{
			OnCreated();
		}

		public FormatDataClassesDataContext(string connection) :
				base(connection, mappingSource)
		{
			OnCreated();
		}

		public FormatDataClassesDataContext(System.Data.IDbConnection connection) :
				base(connection, mappingSource)
		{
			OnCreated();
		}

		public FormatDataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
				base(connection, mappingSource)
		{
			OnCreated();
		}

		public FormatDataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :
				base(connection, mappingSource)
		{
			OnCreated();
		}

		public System.Data.Linq.Table<tblFormat> tblFormats
		{
			get
			{
				return this.GetTable<tblFormat>();
			}
		}
	}

	[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.tblFormat")]
	public partial class tblFormat : INotifyPropertyChanging, INotifyPropertyChanged
	{

		private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

		private int _FormatID;

		private string _FormatName;

    #region Extensibility Method Definitions
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OnFormatIDChanging(int value);
    partial void OnFormatIDChanged();
    partial void OnFormatNameChanging(string value);
    partial void OnFormatNameChanged();
    #endregion

		public tblFormat()
		{
			OnCreated();
		}

		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FormatID", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)]
		public int FormatID
		{
			get
			{
				return this._FormatID;
			}
			set
			{
				if ((this._FormatID != value))
				{
					this.OnFormatIDChanging(value);
					this.SendPropertyChanging();
					this._FormatID = value;
					this.SendPropertyChanged("FormatID");
					this.OnFormatIDChanged();
				}
			}
		}

		[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_FormatName", DbType="VarChar(MAX) NOT NULL", CanBeNull=false)]
		public string FormatName
		{
			get
			{
				return this._FormatName;
			}
			set
			{
				if ((this._FormatName != value))
				{
					this.OnFormatNameChanging(value);
					this.SendPropertyChanging();
					this._FormatName = value;
					this.SendPropertyChanged("FormatName");
					this.OnFormatNameChanged();
				}
			}
		}

		public event PropertyChangingEventHandler PropertyChanging;

		public event PropertyChangedEventHandler PropertyChanged;

		protected virtual void SendPropertyChanging()
		{
			if ((this.PropertyChanging != null))
			{
				this.PropertyChanging(this, emptyChangingEventArgs);
			}
		}

		protected virtual void SendPropertyChanged(String propertyName)
		{
			if ((this.PropertyChanged != null))
			{
				this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
#pragma warning restore 1591

Now I am trying to bind this all to a checked box datagrid in the WPF with code that looks like this:

<Label x:Name="lblMTVAddFormat" Style="{StaticResource Label Style}" Content="Formats" Margin="335,74,0,0" Width="97"/><DataGrid x:Name="dgMTVAddFormat" Margin="437,74,10,265" AutoGenerateColumns="False"><DataGrid.Columns><DataGridCheckBoxColumn Binding="{Binding fBool}" /><DataGridTextColumn Binding="{Binding Path='FormatName'}" /></DataGrid.Columns></DataGrid>
This is all running from a local disk, connected to a remote developer database.  I have no build errors or anything when I go to the debug, hitting continue sends it to another break for the exact same reason.  Which loops out of the program and shuts down the debugger.  Could anyone point me in the direction to go since it is throwing this error on debug? 


Michael R. Mastro II

Mvvm Light and callback

$
0
0

I created a MVVM Light application with Entity Framework through a TextBox where I enter the initials of a name, and after pressing enter opens a second View when using a DataGrid are all names with the same initials. This second View, after you have selected your desired name, closes by selecting in the MainView within the same TextBox which are written the initials.

The code I wrote is working perfectly.

MainViewModel:

namespace DataGridSearch_MvvmLight.ViewModel
{
    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {

        private string _name = string.Empty;
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                Set(() => Name, ref _name, value);
            }
        }
        public RelayCommand SearchCommand { get; private set; }
        public RelayCommand<EventArgs> KeyDown_ParseCommand { get; private set; }

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            SearchCommand = new RelayCommand(() => Search());

            KeyDown_ParseCommand = new RelayCommand<EventArgs>(onKeyDown);
        }

        private void onKeyDown(EventArgs e)
        {
            var pressedKey = (e != null) ? (KeyEventArgs)e : null;

            if (pressedKey.Key == Key.Enter || pressedKey.Key == Key.Tab && pressedKey != null)
            {
                Search();
            }
        }

        private void Search()
        {
            using (var ctx = new MyContext())
            {
                ctx.Configuration.LazyLoadingEnabled = false;

                var query = ctx.Customers
                     .Where(x => x.Name.StartsWith(Name))
                     .OrderBy(x => x.Name)
                     .ToList();

                var vm = new DataGridViewModel(query);
                Messenger.Default.Send(new ModalMessage<DataGridViewModel>(vm, ShowDialogCallback));

            }
        }
        private void ShowDialogCallback(bool confirmed, DataGridViewModel returnedVm)
        {
            if (confirmed)
            {
                Name = returnedVm.SelectedItem.Name;
            }
        }
    }
}

MainWindow.cs:

public partial class MainWindow : Window
    {
        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Closing += (s, e) => ViewModelLocator.Cleanup();

            Messenger.Default.Register<ModalMessage<DataGridViewModel>>(
                this,
                msg =>
                {
                    var dialog = new ViewDataGrid(msg.ViewModel);
                    var result = dialog.ShowDialog();
                    msg.Callback(result ?? false, msg.ViewModel);
                });

ModalMessage.cs:

namespace DataGridSearch_MvvmLight
{
    public class ModalMessage<TViewModel> : MessageBase
    {
        /// <summary>
        /// The ViewModel that supports the modal dialog.
        /// </summary>
        public TViewModel ViewModel { get; private set; }

        /// <summary>
        /// The callback to be performed when the dialog is dismissed.
        /// </summary>
        public Action<bool, TViewModel> Callback { get; private set; }

        public ModalMessage(TViewModel vm, Action<bool, TViewModel> callback)
        {
            ViewModel = vm;
            Callback = callback;
        }
    }
}

DataGridViewModel:

namespace DataGridSearch_MvvmLight.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class DataGridViewModel : ViewModelBase
    {
        Customer _SelectedItem;
        public Customer SelectedItem
        {
            get
            {
                return _SelectedItem;
            }
            set
            {
                Set(() => SelectedItem, ref _SelectedItem, value);
            }
        }

        List<Customer> _Customer;
        public List<Customer> Customer
        {
            get
            {
                return _Customer;
            }
            set
            {
                Set(() => Customer, ref _Customer, value);
            }
        }
        public RelayCommand<EventArgs> MouseDoubleClick_ParseCommand { get; private set; }


        /// <summary>
        /// Initializes a new instance of the DataGridViewModel class.
        /// </summary>
        public DataGridViewModel(List<Customer> listCustomer)
        {
            Customer = listCustomer;
            MouseDoubleClick_ParseCommand = new RelayCommand<EventArgs>(onMouseDoubleClick);

        }
        private void onMouseDoubleClick(EventArgs e)
        {
            var pressedKey = (e != null) ? (MouseButtonEventArgs)e : null;

            if (pressedKey.LeftButton == MouseButtonState.Pressed && SelectedItem != null)
            {
                Application.Current.Windows[1].DialogResult = true;
            }
        }
    }
}

ViewDataGrid.cs:

public partial class ViewDataGrid : Window
    {
        /// <summary>
        /// Initializes a new instance of the ViewDataGrid class.
        /// </summary>
        public ViewDataGrid(DataGridViewModel vm)
        {
            InitializeComponent();
            this.DataContext = vm;
        }
    }

My question is as follows: while the application works properly, is it correct to write in MainViewModel

var vm = new DataGridViewModel(query);

and in DataGridViewModel

public DataGridViewModel(List<Customer> listCustomer)
        {
            Customer = listCustomer; 
according to MVVM?


Possible Bug When Binding Data to ContentPresenter ToolTip Attribute

$
0
0

Hello everyone,

I'm developing a small application using WPF. I have a custom ListBox control which contains a number of CheckBox entries paired up with a ContentPresenter object which displays some text obtained from a custom generic object.

If I bind the ContentPresenter 'Content' node to one of the properties of my class, it will display the text I want correctly. However, I cannot do the same with its 'ToolTip' attribute.

Here's an excerpt of my XAML.

<Window.Resources><local:SandboxProfiles x:Key="profiles"/><DataTemplate x:Key="ListBoxItemTemplate"><!-- The ToolTip attribute doesn't accept dynamic data bindings (maybe a bug?) within the ContentPresenter node.
            Therefore, the attribute has to be inserted in the parent node (WrapPanel) for it to work. --><WrapPanel ToolTip="{Binding Element.FriendlyDescription}"><CheckBox IsChecked="{Binding IsSelected}" VerticalAlignment="Center" /><ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" Margin="2,0" /></WrapPanel></DataTemplate></Window.Resources>

This line works absolutely fine like this,

<ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" Margin="2,0" />

However, this doesn't work

<ContentPresenter Content="{Binding Element.TypeString, Mode=OneTime}" ToolTip={Binding Element.TypeString} Margin="2,0" />

Note I'm using the exact same pattern here, only that I'm applying it to the ToolTip attribute instead of Content. This doesn't work. It compiles, no exceptions, but no tooltip is displayed.

However, if I bind the ToolTip attribute of the CheckBox node or the parent WrapPanel node in the exact same way, itdoes work. This works,

<WrapPanel ToolTip="{Binding Element.TypeString}">

And this works too,

<CheckBox IsChecked="{Binding IsSelected}" ToolTip="{Binding Element.TypeString}" VerticalAlignment="Center" />

I've searched the documentation and nowhere does it say I should expect ContentPresenter's 'ToolTip' attribute to behave differently than with any other XAML component.

This has led me to believe this is a bug in the WPF runtime. If, on the other hand, I'm missing something here, please, do let me know.

Thank you.


printPreviewDialog in WPF

$
0
0

I'm translating a project from C# to WPF.

In C# I have 

  private void btnPrint_Click(object sender, EventArgs e)
        {
            if (printDialog1.ShowDialog() == DialogResult.OK)
            printPreviewDialog1.ShowDialog();
        }

In WPF I have 

  private void btnPrint_MouseDown(object sender, MouseButtonEventArgs e)
        {
            PrintDialog printDialog1 = new PrintDialog();

            if (printDialog1.ShowDialog().ToString().Equals("OK"))
                printPreviewDialog1.ShowDialog();
        }
I succeed to define printDialog1

But I didn't manage to define  printPreviewDialog1.

Here my libraries 

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.IO; using System.Drawing.Printing; using System.ComponentModel; using System.Data; using System.Drawing; using LibLogic; using UserControls; using System.Runtime.Serialization.Formatters.Binary; using System.Printing; using System.Timers; using Microsoft.Win32;

What shoul I do ?

a function DrawGeometry not recognised in WPF

$
0
0

Hello

I'm transleting project from C# to WPF

In C#, I have : 

 drawingContext.DrawGeometry.DrawPolygon(new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 3), p);

In WPF, DrawGeometry is not recognise and I have the libraries

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LibLogic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

I have an error

'System.Windows.Media.DrawingContext.DrawGeometry(System.Windows.Media.Brush, System.Windows.Media.Pen, System.Windows.Media.Geometry)' is a 'method', which is not valid in the given contextZ:\WPF\Kakuro WPF 22_02_2015\UserControls\Triangle.xaml.cs7628UserControls

What should I do ?

Form

$
0
0

I would like to bring two forms side by side;

this.Location = new Point((form1.Location.X + form1.Width), form1.Location.Y);

How can I do with WPF;

And

I'm doing it this way,But how is done by another method;

       private void Window_Activated(object sender, EventArgs e)
        {
            MainForm v=new MainForm();
            this.Top = v.Top;
            this.Left = v.Left + v.Width;
        }
Thanks;


Custom Slider

$
0
0
Hi,

My problem is that I just wanted to change the slider's color, but after managing to do it, the thumb (is this the correct word? I'm not English) is of the wrong dimension, because its height is the same as the rest of the bar, while I wanted for it to be higher. I wanted the thumb to be height 20 and the rest of the bar to be 5, similar to the regular one, but of another color.

Thanks for the attention.

This is my code so far in my windows .xaml:

 
<Window.Resources><Style TargetType="Thumb" x:Key="SliderThumbStyle"><Setter Property="BorderThickness" Value="1" /><Setter Property="BorderBrush" Value="#FFDCD09B" /><Setter Property="Background" Value="#FFDCD09B" /><Setter Property="Height" Value="20" /><Setter Property="Width" Value="11" /><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="Thumb"><Border Background="{TemplateBinding Background}"
                                                BorderBrush="#FFDCD09B"
                                                BorderThickness="1" /></ControlTemplate></Setter.Value></Setter></Style><Style x:Key="ivoryslider"  TargetType="{x:Type Slider}"><Setter Property="Template"><Setter.Value><ControlTemplate><Grid Margin="0,0,0,0"><Grid.RowDefinitions><RowDefinition Height="5" /></Grid.RowDefinitions><Track Grid.Column="1"   Name="PART_Track"><Track.DecreaseRepeatButton><RepeatButton Command="Slider.DecreaseLarge" Background="#FFDCD09B"/></Track.DecreaseRepeatButton><Track.IncreaseRepeatButton><RepeatButton Command="Slider.IncreaseLarge" Background="#FFDCD09B"/></Track.IncreaseRepeatButton><Track.Thumb ><Thumb Style="{StaticResource SliderThumbStyle}" /></Track.Thumb></Track></Grid></ControlTemplate></Setter.Value></Setter></Style></Window.Resources>


Fill text box's from one text box entry

$
0
0
I have a text file with city state and zip codes when the zipcode text box lost focus i want to fill the corresponding city and state texbox's.

WPF - Questions & Answers - Survey Application

$
0
0

Hi guys,

I need your help to create some window form or WPF questions & answers Survey application. The output exe should be configurable by admin user like to add / modify questions.. Candidate user allowed to attempt any no of questions and they will be provided with final results..My doubt is , how we can maintain those configurable questions & answers within.net exe itself. so that candidate user don't have access to it..

any thoughts?

Regards

bala


Location in WPF

$
0
0

I have in C# . 

 matCell[i, j].Height = (double.Parse((Logic.HEIGHTMISH - 2).ToString()));
 matCell[i, j].Width = (double.Parse((Logic.WIDTHMISH - 2).ToString()));
 matCell[i, j].Location = new Point(j * Logic.WIDTHMISH, i * Logic.HEIGHTMISH);
I want to translate it in WPF

WPF knows Heigt and WIdth but not Location. How can I write yhe Location in WPF ?


the function Dispose

$
0
0

I'm transleting a project from C# to WPF

In C# I have a function Dispose

board.Dispose();

 In WPF it doesn't work. How can I write this in WPF ?

I have an error

'UserControls.Board' does not contain a definition for 'Dispose' and no extension method

'Dispose' accepting a first argument of type 'UserControls.Board' could be found

(are you missing a using directive or an assembly reference?)


Bind List of Items to Combobox

$
0
0

Hi,

I have a ComboBox defined in my XAML file.  Originally I set the ItemsSource to a CollectionViewSource of 'User' objects.  This worked perfectly fine until I had two ComboBox's binded to the same CollectionViewSource, and every time I changed one ComboBox, the other also changed.

I decided I would bind my second ComboBox to a list of <User> objects.  However, how do I define a WPF List of type <User> in my XAML file?

My list in the code-behind file is defined in the following way:

List<User> userList2 = _context.Users.OrderBy(a => a.Firstname).ToList();

How do I bind my ComboBox to the list created above?

Thanks

Chart Controls in Visual Studio 2010

[WPF] Select all columns

$
0
0

Hi,

I would insert a column for "Select all" checkbox in each rows.

In my XAML, I inserted:

<DataGridTemplateColumn><DataGridTemplateColumn.Header><CheckBox Name="chkbxSelectAll" PreviewMouseLeftButtonDown="chkbxSelectAll_PreviewMouseLeftButtonDown"></CheckBox></DataGridTemplateColumn.Header><DataGridTemplateColumn.CellTemplate><DataTemplate><CheckBox x:Name="CheckBox"
		  PreviewMouseLeftButtonDown="CheckBox_PreviewMouseLeftButtonDown" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>


The method CheckBox_PreviewMouseLeftButtonDown:

private void CheckBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
	var chk = (CheckBox)sender;
	var row = VisualTreeHelpers.FindAncestor<DataGridRow>(chk);
	var newValue = !chk.IsChecked.GetValueOrDefault();

	row.IsSelected = newValue;
	chk.IsChecked = newValue;

	e.Handled = true;
}


and it works fine.

How can I work "Select all" in the header?

Thanks.

Viewing all 18858 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>