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

Styles & Resource Dictionaries

$
0
0

Hello,

I am new to WPF and I'm really enjoying using Microsoft Blend 2015. I am looking for more information on how to style elements. 

I am styling a button and it's a specific button (a button that closes the application). I will have 2 other buttons, minimize and maximize, they are going to have the same properties as the close button. 

I would like to use a resource dictionary to hold all my style markup for these 3 buttons so that my style markup doesn't have to be included in my MainWindow.xaml markup in a Window.Resource tag (for me this makes things really cluttered).

How can I make my resource dictionary only affect these 3 buttons. I have my 3 buttons inside a Grid layout but I'm unsure where to place the resource dictionary in my markup. I understand that I can place <Application.Resources> in my App.xaml but this will affect all buttons inside my application which isn't what I would like to do, and placing my resource dictionary inside <Window.Resources> would affect all the buttons in that particular window. How would I get my resource dictionary to only effect the 3 buttons inside of a particular window?


A popup that blocks tooltips of a parent control as long as it's open.

$
0
0
Hello. The topic says for itself. I have a control and I want to block all its tooltips when popup of a combobox is open. Looks like I need somewhat a modal popup. Thanks in advance.

Using ListCollectionView.CustomSort gives me duplicate entries

$
0
0

I'm not sure what I'm seeing here.

My application adds lots of items to an ObservableCollection in multiple threads. To make dispatching to the UI thread any efficient, I queue the CollectionChanged events and only raise them in the UI thread on request, instead of dispatching every single event to the UI thread.

This alone works fine. But when I also use CustomSort of the ListCollectionView, I get mostly duplicate items in the list on the screen.

Where do they come from? Is ListCollectionView broken? Or is there another problem in my DispatchedObservableCollection implementation with event queueing?

I have made a small sample application that you can find here.

URI

$
0
0


In my progect i have folder Source. In this folder i have image start.png. Why when I add Source in XAML <Image Source ="Source\start.png"> Visual Studio search Source in C:\... When my progect Located on J:\..

Main diffrence between DependencyProperty and normal Property

$
0
0

Hi ,

Anybody tell me , main difference between Dependency property and normal property  with exmaple or DEMO.

Thanks,

Aniruddha acharya


A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

DropDown List Inable and Disable

$
0
0

Hi ,

I am using two controls first CheckBox and second DropDownList . My query is when i check checkbox than dropdown list enabled.

and when i unchecked checkbox than dropdownlist disable.

How its possible using Converter or binding.

Please find attached  scenario Image . look at 

Thanks,

Aniruddha acharya


A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

MVVM

$
0
0

Hi to all,

Please anybody can give me a best example of data flow in MVVM project architecture . using SQL database .

How to relation create or data flow between ViewMode and Mode And How to data show on View side from Model classes.

Please send me any best example.

Thanks,

Aniruddha acharya


A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Need to create a circular seekbar for a UWP

$
0
0

I am a naive UWP developer. Can any one help me out with a circular seekbar which i need to create in XAML for setting temperature by dragging a small circle lying on its circumference.


[WPF] How to restrict the popup from closing while click on a Windows Forms element?

$
0
0

Hi All,

I am using WinForms and WPF button inside a Popup. I want StaysOpen to be false.

Clicking WinForms button closes the popup whereas it does not happens with WPF button.

Is it possible to restrict this behavior? I want the popup to close when I click outside it.

<StackPanel  ><Button Content="Open popup" Name="buttonpopup" Click="Button_Click" HorizontalAlignment="Center" Margin="0 20 0 0"/><!--Adding WFH in the Dock Panel--><Popup StaysOpen="False" Focusable="False" PlacementTarget="{Binding ElementName=buttonpopup}" Placement="Bottom" Name="pop" IsOpen="True" VerticalOffset="20"><Border BorderBrush="Black" BorderThickness="1" ><Grid><Grid.RowDefinitions><RowDefinition Height="40"/><RowDefinition/></Grid.RowDefinitions><Button Content="Click WPF button" Margin="10"/><wfi:WindowsFormsHost Height="Auto" Focusable="False" Width="Auto" Grid.Row="1"><wf:Button x:Name="Button" Text="Click WF Button" /></wfi:WindowsFormsHost></Grid></Border></Popup></StackPanel>
private void Button_Click(object sender, RoutedEventArgs e)
        {
            pop.IsOpen = true;
        }  

Regards,

Jessie


Focus not getting set on a combobox

$
0
0
I've a C#/WPF application.On my view,I need to set focus on a combobox on click of Clear button.
My code is as per below and I dont see focus getting set on the combobox.Could you advise what am I missing here please?

Thanks.

MyView:

    <ComboBox x:Name="cboManager" Grid.Column="2" IsEnabled="{Binding EnableManagerView}" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="3" VerticalAlignment="Top" Width="195" Height="22" SelectedItem="{Binding MyViewModel.SelectedManager}" ItemsSource="{Binding MyViewModel.Managers}" Style="{DynamicResource ManagerStyle}" Text="{Binding MyViewModel.Manager}" DisplayMemberPath="Description" SelectedValuePath="Code" TabIndex="1"/>

MainWindowResources.cs:

    <DataTrigger Binding="{Binding Path=FocusOnDealManager}" Value="true">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=cboManager}"/>
            </DataTrigger>

MyViewModel:

    private void Clear()
    {
           
     this.FocusOnDealManager = true;
    }
    public bool FocusOnDealManager
            {
                 get; set; 
            }


Note: MyViewModel class inherits ViewModelBase which implements INotifyPropertyChanged interface. Other functionalities like setting background color on a textbox,etc. using style are working.Its just that the focus on combobox is not working.

WPF How to make CONVERTER in a DataGrid with DataGridTextColumn created in code

$
0
0

I create datagridtextcolumn by code dynamicly. But in these way, the converter cannot work correctly.

<Window x:Class="MethodConfiguration.ShowTable"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MethodConfiguration;assembly="
        Title="ShowTable" Height="372" Width="892" Loaded="Window_Loaded"><Window.Resources><local:DataSourceConvert x:Key="dataSourceConvert"/></Window.Resources><Grid x:Name="gridMain"><DataGrid x:Name="dataGrid" AutoGenerateColumns="True" SelectionUnit="Cell"><DataGrid.CellStyle><Style TargetType="DataGridCell"><Setter Property="Background" Value="{Binding BackgroundColor,Converter={StaticResource dataSourceConvert}}"/></Style></DataGrid.CellStyle></DataGrid></Grid></Window>

Above is to define CellStyle of datagrid. And see converter definition below:

 public class DataSourceConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            switch ((string)value)
            {
                case "SMP":
                    return new SolidColorBrush(Colors.Pink);
                case "MID":
                    return new SolidColorBrush(Colors.Blue);
                case "INC":
                    return new SolidColorBrush(Colors.Orange);
                case "ACT":
                    return new SolidColorBrush(Colors.Green);
                case "DIS":
                    return new SolidColorBrush(Colors.Gray);
                case "RED":
                    return new SolidColorBrush(Colors.Yellow);
                default:
                    return new SolidColorBrush(Colors.White);
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }
    }

The background is binding with "backgroundColor" and it will be changed in Converter. The column is created by the following way:

void AddColumn(TimeUnit timeUnit)
        {
            string timeUnitName = "timeUnit" + newColumnIndex;
            //This is to save origin value of background
            //Converter will analyse this value and change it into Brush for DataGridCell Background
            string backgroundColor = "BackgroundColor";
            DataGridTextColumn dataGridTextColumnNew = new DataGridTextColumn() { Header = newColumnIndex.ToString(), Binding =new Binding( timeUnitName) };
            _dataGrid.Columns.Add(dataGridTextColumnNew);
            foreach (Step step in timeUnit.StepList)
            {

                string stepType;
                switch(step.StepType)
                {
                    case EStepType.ADDSAMPLESTEP:
                        stepType = "SMP";
                        break;
                    case EStepType.ADDMIDDLER1STEP:
                        stepType="MID";
                        break;
                    case EStepType.ADDACTIVATORR2STEP:
                        stepType="ACT";
                        break;
                    case EStepType.INCUBATIONSTEP:
                        stepType="INC";
                        break;
                    case EStepType.READTESTSTEP:
                        stepType="RED";
                        break;
                    case EStepType.DISPOSEWELL:
                        stepType="DIS";
                        break;
                    default:
                        stepType="NAN";
                        break;
                }
                foreach (dynamic item in items)
                {
                    if (step.Test.Patient.PatientCode == item.PatientCode)
                    {
                        item.TrySetMember(new SetPropertyBinder(timeUnitName), stepType);
                        //save the mark value in backgroundColor
                        item.TrySetMember(new SetPropertyBinder(backgroundColor), stepType);
                        break;
                    }
                }
            }
        }

At last Ifind all the cell is yellow. I follow the code and I find all the background of each cell is "RED" and the color is all yellow.

In fact only the backgroundColor value  of the last part cell of datarow is "RED". Not all.

Please tell me anything wrong in my program?

ViewModel Not Updating

$
0
0

I have a simple MVVM pattern but something strange is happening and I am not sure why?
I have a MODEL

public class SamplePickupModel
    {
        public string InboxDirectory { get; set; }
        public string ImportDirectory { get; set; }
        public string NextImport { get; set; }
    }

And a simple VIEWMODEL

public class SamplePickupViewModel : ViewModelBase
    {
        DispatcherTimer dispatcherTimer;

        private const int NEXTSGSIMPORT = 20;

        private string BaseInboxDirectory = @"R:\0400_GIM\Working\Quentin_Samuelson\Projects\Automation\Inbox";
        private string BaseImportDirectory = @"R:\0400_GIM\Working\Quentin_Samuelson\Projects\Automation\Data Import";
        private string SamplePickupFolder = @"Sample Pickup";
        private string sgsSamplePickupFolder = @"SGS Sample Pickup";



        public SamplePickupViewModel()
        {

            SgsSamplePickups = new Model.SamplePickupModel();

            DateTime nextsgsPickup = Helpers.DateTimeHelper.RoundUp(DateTime.Now, TimeSpan.FromSeconds(NEXTSGSIMPORT));
            TimeSpan timeDiff = nextsgsPickup.Subtract(DateTime.Now);

                dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render);
                dispatcherTimer.Interval = timeDiff;
                dispatcherTimer.Tick += (sender, args) =>
            {
                Debug.WriteLine("Here");
                SgsSamplePickups.NextImport = "Later";
                test = "Later";
            };
                dispatcherTimer.Start();

            SgsSamplePickups.NextImport = "Now";
            test = "Now";
        }


        private string m_test;
        public string test
        {
            get
            {
                return this.m_test;
            }
            set
            {
                if (m_test == value)
                    return;
                m_test = value;
                OnPropertyChanged("test");
            }
        }
        private Model.SamplePickupModel m_SgsSamplePickups;
        public Model.SamplePickupModel SgsSamplePickups
        {
            get { return m_SgsSamplePickups; }
            set { SetProperty(ref m_SgsSamplePickups, value); }
        }

    }

When the dispatcher fires, it updates the string test but not the Model SgsSamplePickup.
If I implement INotifyPropertyChanged on the Model, it does update.
I always thought the INotifyPropertyChanged should be on the ViewModel and not the Model or both?

What I am after is when a field in the Model (SgsSamplePickups) is modified, it updates the ViewModel and hence the view.

Regards

buttons acting as arrow keys in wpf

$
0
0
On treeview, when i hit left arrow in keyboard the selected item in treeview expands and when i hit down arrow key the next item in the treeview is selected..So here I have two Buttons btnStepIn, btnStepOut which should exactly act like left and down arrow key..On btnStepIn button click right arrowkey functionality should be performed and on btnStepOut button click down arrow key functionality should be performed..

Xbap applications do no longer scale correct on high dpi pc's after win10 anniversary update

$
0
0

After having updated with win10 anniversary update, we having scaling issues on the xbap applications we use.

The clients affected use 150% or 200% scaling in their display settings.

Not sure if this is .net framework issue or Internet explorer issue, but this is very much blocking these client pc's of using the applications now. Only workaround is currently using 100% scaling and using lower resolution, which is a pity of course.

Example: any website hosting an Xbap application, like http://weathernews.com/wpfglobal.xbap for example

Elementhost and derived WPF class

$
0
0

Hello,

I have a wpf class derived from System.Windows.Controls.Button

-- --- JButtonWPF.cs ---

using System.Windows;
using System.Windows.Controls;

namespace Jedox.Controls
{
    public partial class JButtonWPF : Button
    {
        public JButtonWPF()
        {
            dynamic ds = TryFindResource(ToolBar.ButtonStyleKey);
            if (ds is Style)
            {
                this.Style = ds;
            }
        }
    }
}

( This class has normally more code, but to create my Problem this is sufficient.)

Now I want to host an object of this type in one Windows.Form Dialog.

JButtonWPF Wpfb = new JButtonWPF();

this.btn_user.Child = Wpfb;

this.btn_user.PropertyMap.Remove("BackColor");
this.btn_user.PropertyMap.Remove("BackgroundImage");
this.btn_user.PropertyMap.Remove("BackgroundImageLayout");

When I open the dialog I see a black square, but when I move the mouse over the the button I see a gray  square.

When I comment out the line

this.Style = ds

in JButtonWPF.cs I see  gray square which doesn't Change when I move the mouse over the button, but the button isn't flat anymore.

So how can I achieve that this button has a "flat" style, but doesn't change automagically the Background.

tia

  Hendrik Schmieder


WPF GridView column cannot sort

$
0
0

Hi,

I want to sort the column by click the header.

I follow the method below.

https://code.msdn.microsoft.com/windowsdesktop/Sorting-a-WPF-ListView-by-5769086f#content

but cannot success.

it throws exception in this line resultDataView.SortDescriptions.Clear() - System.NotSupportedException.

I check the attribute of resultDataView.

ICollectionView resultDataView = CollectionViewSource.GetDefaultView(lvSelectableOpenPosition.ItemsSource);

CanSort=false.

I don't know it is related or not.

Please help.

My program:

    public partial class SelectableOpenPositionView : UserControl
    {
        private ListSortDirection _sortDirection;
        private GridViewColumnHeader _sortColumn;

        public SelectableOpenPositionView()
        {
            InitializeComponent();
        }

        private void SecondResultDataViewClick(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader column = e.OriginalSource as GridViewColumnHeader;
            if (column == null)
            {
                return;
            }

            if (_sortColumn == column)
            {
                // Toggle sorting direction
                _sortDirection = _sortDirection == ListSortDirection.Ascending ?
                                                   ListSortDirection.Descending :
                                                   ListSortDirection.Ascending;
            }
            else
            {
                // Remove arrow from previously sorted header
                if (_sortColumn != null)
                {
                    _sortColumn.Column.HeaderTemplate = null;
                    _sortColumn.Column.Width = _sortColumn.ActualWidth - 20;
                }

                _sortColumn = column;
                _sortDirection = ListSortDirection.Ascending;
                column.Column.Width = column.ActualWidth + 20;
            }

            if (_sortDirection == ListSortDirection.Ascending)
            {
                column.Column.HeaderTemplate =
                                   Resources["HeaderTemplateArrowUp"] as DataTemplate;
            }
            else
            {
                column.Column.HeaderTemplate =
                                    Resources["HeaderTemplateArrowDown"] as DataTemplate;
            }

            string header = string.Empty;

            // if binding is used and property name doesn't match header content
            Binding b = _sortColumn.Column.DisplayMemberBinding as Binding;
            if (b != null)
            {
                header = b.Path.Path;
            }
            //lvSelectableOpenPosition.Items.SortDescriptions.Clear();
            //lvSelectableOpenPosition.Items.SortDescriptions.Add(new SortDescription(header, _sortDirection));

            ICollectionView resultDataView = CollectionViewSource.GetDefaultView(lvSelectableOpenPosition.ItemsSource);
            resultDataView.SortDescriptions.Clear();
            resultDataView.SortDescriptions.Add(new SortDescription(header, _sortDirection));
        }
    }

xaml

<UserControl x:Class="Administrator.View.OpenPositions.SelectableOpenPositionView"
    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"
    mc:Ignorable="d"
    >
            
    <UserControl.Resources>
        <ResourceDictionary>
            <DataTemplate x:Key="HeaderTemplateArrowUp">
                <DockPanel LastChildFill="True" Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GridViewColumnHeader}}}">
                    <Path x:Name="arrowUp" StrokeThickness="1" Fill="Gray" Data="M 5,10 L 15,10 L 10,5 L 5,10" DockPanel.Dock="Right" Width="20" HorizontalAlignment="Right" Margin="5,0,5,0" SnapsToDevicePixels="True"/>
                    <TextBlock Text="{Binding }" />
                </DockPanel>
            </DataTemplate>

            <DataTemplate x:Key="HeaderTemplateArrowDown">
                <DockPanel LastChildFill="True" Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GridViewColumnHeader}}}">
                    <Path x:Name="arrowDown" StrokeThickness="1" Fill="Gray"  Data="M 5,5 L 10,10 L 15,5 L 5,5" DockPanel.Dock="Right" Width="20" HorizontalAlignment="Right" Margin="5,0,5,0" SnapsToDevicePixels="True"/>
                    <TextBlock Text="{Binding }" />
                </DockPanel>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>

    <Grid>
        <ListView x:Name="lvSelectableOpenPosition"
                  ItemsSource="{Binding RecordList}"
                  IsEnabled="{Binding IsEnabled}"
                  Grid.Row="1"
                  GridViewColumnHeader.Click="SecondResultDataViewClick">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <!--<GridViewColumn Header="{StaticResource Common_Ref}" DisplayMemberBinding="{Binding Path=Record.Ref}"/>-->
                        <GridViewColumn DisplayMemberBinding="{Binding Path=Record.Ref}">
                            <GridViewColumnHeader Content="{StaticResource Common_Ref}" />
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>    
</UserControl>

MEF and Prism6

$
0
0

First of all is there a better forum for this question?
I am trying to understand Prism and MEF and can make it work with a single module in a directory.
The modules are very simple, just putting a message into a region.  They are all of type IFunction and are decorated with:-  
    [ModuleExport(typeof(IFunction))]
    [ExportMetadata("data","ABC")]
    public class ModuleAModule : IModule, IFunction
    {......
where Ifunction is an interface with just an Initialize method
What I am trying to do is get the modules into the IEnumerable 'functions' so I can get at them (eg to make a menu) but whatever I do 'functions' stays null although the module are put in the catalogue.
One message I get, which does not cause an design or run time error, is:
error CS1503: Argument 1: cannot convert from 'System.ComponentModel.Composition.Primitives.ComposablePartCatalog' to 'System.ComponentModel.Composition.Hosting.DirectoryCatalog'
With MEF Bootstrapper doing so much I find it very difficult to work out what is going on and debug.
The code below was drawn from reading a lot of tutorials.  Some were pretty old and that might be part of my difficulty, Prism and MEF are still changing pretty fast.
Can anyone point me in the right direction, or to an up-to-date sample or tutorial.

    public class Bootstrapper : MefBootstrapper
    {
        [ImportMany(typeof(IFunction))]
        public IEnumerable<Lazy<IFunction, IFunctionData>> functions { get; set; }
        protected override DependencyObject CreateShell()
        {
            return Container.GetExportedValue<MainWindow>();
        }
        protected override void InitializeShell()
        {
            Application.Current.MainWindow.Show();
        }
        protected override void ConfigureAggregateCatalog()
        {
            base.ConfigureAggregateCatalog();
            AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
            string dir = General.ModuleDirectory;  // from elsewhere in the program
            DirectoryCatalog catalog = new DirectoryCatalog(dir);
            AggregateCatalog.Catalogs.Add(catalog);
        }
        protected override void ConfigureViewModelLocator()
        {
            base.ConfigureViewModelLocator();
            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver(viewType =>
            {
                var viewName = viewType.FullName;
                viewName = viewName.Replace(".Views.", ".ViewModels.");
                var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
                var suffix = viewName.EndsWith("View") ? "Model" : "ViewModel";
                var viewModelName = String.Format(CultureInfo.InvariantCulture, "{0}{1}", viewName, suffix);
                var assembly = viewType.GetTypeInfo().Assembly;
                var type = assembly.GetType(viewModelName, true);
                return type;
            });
        }
    }


John Meers

Wpf NumericDatagrid Column

$
0
0

Hai 
I want to create Numeric text box in datagrid user control. I have created using below code andf it is working fine.
My problem is when I type grid numeric cell allows first key alphabet, then it restricts alphabet and allows only digits.


In WGrid XAML

<DataGrid x:Class="WpfGrid.WGrid"
             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:WpfGrid"
             mc:Ignorable="d"
             d:DesignHeight="300" Width="500" PreviewKeyDown="DataGrid_PreviewKeyDown" BeginningEdit="DataGrid_BeginningEdit" SelectionMode="Single" SelectionUnit="Cell" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" CanUserResizeColumns="False" EnableRowVirtualization="False"></DataGrid>


namespace WpfGrid
{
    public partial class WGrid : DataGrid
    {

        public WGrid()
        {
            InitializeComponent();
        }

    }
    public class DataGridNumericColumn : DataGridTextColumn
    {
        protected override object PrepareCellForEdit(System.Windows.FrameworkElement editingElement, System.Windows.RoutedEventArgs editingEventArgs)
        {
            TextBox edit = editingElement as TextBox;
            edit.PreviewTextInput += OnPreviewTextInput;
            return base.PrepareCellForEdit(editingElement, editingEventArgs);
        }
        void OnPreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
        {
            e.Handled = new Regex("[^0-9.]").IsMatch(e.Text);
        }
    }
}

After Creating this control I added this on a new WPF application

XAML

<Window x:Class="WpfGrid.MainWindow"
        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"
        xmlns:local="clr-namespace:WpfGrid"
        mc:Ignorable="d"
        Title="MainWindow" Height="475" Width="785" Background="#FF45A7B8"><local:WGrid x:Name="Dgv" HorizontalAlignment="Left" Height="383" Margin="51,39,0,0" VerticalAlignment="Top" Width="674" DbfInsert="Dgv_DbfInsert" RowHeaderWidth="{DynamicResource {x:Static SystemParameters.CaretWidthKey}}" GotoGolumn="Dgv_GotoGolumn" ><local:WGrid.Columns><DataGridTextColumn Binding = "{Binding Path=Name}" ClipboardContentBinding = "{x:Null}" Header = "Name" Width = "200" /><local:DataGridNumericColumn Binding = "{Binding Path=Weight}" Header="Weight" Width = "100" /><DataGridTextColumn Binding = "{Binding Path=Amount}" ClipboardContentBinding = "{x:Null}" Header = "Amount" Width = "100" /></local:WGrid.Columns></local:WGrid></Window>


and in form

 public partial class MainWindow : Window
    {
        ObservableCollection<Customer> collection = new ObservableCollection<Customer>();
        public MainWindow()
        {
            InitializeComponent();
            collection.Add(new Customer());
            Dgv.ItemsSource = collection;
        }
        public class Customer
        {
            public string Name { get; set; }
            public Decimal Weight { get; set; }
            public Decimal Amount { get; set; }

        }

 On running this  DataGridNumericColumn  allows first character alphabet after that it restricts.
Please tell me how to correct this problem. User Control name is WGrid.

Thanks.


programmer



WPF - Is is possible to use "Late Binding" for WPF application?

$
0
0

Say I have a listview control on the WPF grid, and load the data from Sql Server.

Is it possible to use late binding in WPF application?  Or WPF allows early binding only?

Please help

Setting cell background for autogenerated grid columns

$
0
0

I need to set the auto generated grid cell background for columns with a certain group ID. The number of columns in each group are dynamic.If the cell value is less than or equal to 10 i need to set the cell background to a particular color. I may not use code behind for this issue. 

Viewing all 18858 articles
Browse latest View live


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