KushMishra 38 Senior Technical Lead

You can create a public property instead of a variable of type string and put that in a public class, then you inherit that class into the one you are using and can therefore, easily access that property's value.
Hope that helps :)

KushMishra 38 Senior Technical Lead

That's fine...I will keep on trying though and when I would find a solution, I'll surely post it here too...Thanks a lot for your suggestions and help :)

KushMishra 38 Senior Technical Lead

I did not took the old dll's and exe's...I have tried these steps already by deleting these references and rebuilding the solution again but still does not works for me.
The most important thing I want to find before making it look better is what exactly may be causing this problem so that I could identify that culprit and make the solution go ahead :)

KushMishra 38 Senior Technical Lead

I did this one too but still the same, looks like I already got the latest version.

KushMishra 38 Senior Technical Lead

"When an elephant is in trouble, even a frog kicks him"

KushMishra 38 Senior Technical Lead

How to do that, not exactly sure ?

KushMishra 38 Senior Technical Lead

I think you may try what "cgeier" has suggested. Hope that would help you.

KushMishra 38 Senior Technical Lead

Tried this one too but didn't work :(

KushMishra 38 Senior Technical Lead

Could you please demonstrate the same by giving a brief instance ?

KushMishra 38 Senior Technical Lead

Hello All,

I want to design a DataGrid similar to the one in the design picture attached with this article (Please see the pic attached).
I want the following bindings and features :-

  1. The first column of every Item (Item1,...Item5) for (LineNo=1....LineNo=?) will get bind to "Unit" which is not a collection type or array but its just and a String type property. Similarly, the other columns also are not of collection type but just one property that are Unit (String), Status (String), UnitType (String) and Runtime (Integer).

  2. The object, "MyObj" from which I am getting these property values is of collection type like array and has structure as follows :-

MyObj(0) contains Unit, Status, UnitType, Runtime, ItemNo=1, LineNo=1.
MyObj(1) contains Unit, Status, UnitType, Runtime, ItemNo=2, LineNo=1.
MyObj(2) contains Unit, Status, UnitType, Runtime, ItemNo=3, LineNo=1.
MyObj(3) contains Unit, Status, UnitType, Runtime, ItemNo=4, LineNo=1.
MyObj(4) contains Unit, Status, UnitType, Runtime, ItemNo=5, LineNo=1.
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
. .. .. .. .. .. .. .. .. .. .. .. .. .. .
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=1, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=2, LineNo=?.
MyObj(?) contains Unit, Status, UnitType, Runtime, ItemNo=3, LineNo=?.
MyObj(?) …

KushMishra 38 Senior Technical Lead

Everything's going fine as expected but as debugging stops a white window appears but the user controls do not load in that....I tried the same code in my friend's computer and amazingly, it worked as expected (no white screens), so I thought it might have been a system problem and I formatted my hard disk and again set up the same environment but again facing the same issue.

KushMishra 38 Senior Technical Lead

Could anyone please suggest some approach to solve this problem as I am facing this problem for almost 4 weeks and still unable to find an appropriate solution for the same.

KushMishra 38 Senior Technical Lead

I already did this debugging thing however still unable to resolve the same.

KushMishra 38 Senior Technical Lead

Hey, I did this one by my own but thanks for your replies anyways :)

KushMishra 38 Senior Technical Lead

Hello All,

I have experienced a very strange problem in my application.
When I launch my WPF application, it loads fine with a window and button, upon clicking the button, it launches another form which is also fine but in this second form, when I click some button, it launches a window with a blank screen (yet I am quite sure it has got many controls to show on the screen).
I have already checked DelegateCommand, Events, Methods but still facing the same issue.
I tried deleting some files as suggested by Google in "C:\Windows\ServiceProfiles\LocalService\AppData\Local" as ~FontCache-S-1-5-21-2260904419-1400770398-4175912926-283977.dat, ~FontCache-System.dat, ~FontCache-FontFace.dat but still it doesn't works out for me.
The error I'm getting is in mscorlib.dll and PresentationFramework.dll which is in the .Net Framework and also a wierd error as A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

KushMishra 38 Senior Technical Lead

Actually I was trying to get the data through ADO.Net in WinForms for a DataGridView, I don't think these suggestions would work for me :)

KushMishra 38 Senior Technical Lead

Hello,

I have a scenario where I fetch all the records from a database table using ADO.Net and I want to convert one of the column values which has either "0" or "1". If 0, then "No" should be replaced with 0 and if 1, then it should be "Yes".
For instance, if the following data is there in the table :-

  • Item1 1
  • Item2 0
  • Item3 1

then, it should display in the DataGridView as :-

  • Item1 Yes
  • Item2 No
  • Item3 Yes

Any help is appreciated whether in C# or VB.Net.

KushMishra 38 Senior Technical Lead

Another one..but this time its someone else's.....

"Fear is the lack of faith" :)

KushMishra 38 Senior Technical Lead

@diafol...No need for apologies man, I really appreciate if someone helps me to grow by pointing out where I could do better...So, no matter what you perceived of "self-created", it will surely help me in future :)

@ddanbe...Good one indeed :)

KushMishra 38 Senior Technical Lead

Haha...will try another one then some day :)

KushMishra 38 Senior Technical Lead

Could you please post in the full method for the enter command ?

KushMishra 38 Senior Technical Lead

One self-created (hope you would like it)...

"Let go of the fears that have bounded you for years,
Let go of the ego that has always stopped you to grow.
Now is the time you will do something better,
Now is the era when the souls will shatter.
For you have travelled and come so far,
And now you will travel behind the big star.
Care for all and forgive them now,
Respect your self and the world will bow.
Today is the day you've waited so long,
So go and tell this day this very song.
The future is ours and ours all alone,
Pick up yourself and reach the milestone".

KushMishra 38 Senior Technical Lead

No, unfortunately this thread was sort of dead since many days but I would appreciate if someone could possibly help me around with this as I still haven't found any solution for the same.

KushMishra 38 Senior Technical Lead

Hey, I found a solution to this one (however not exactly using the EventSetter but an easy replacement though). Just used Interaction command and parameter to be passed in the main DataGrid. I know it is not a perfect solution to the EventSetter problem but I am sure its the other way round of solving this problem also :)

<UserControl x:Class="MyWPFPracticeApp.Views.MyDataGridResearch"
             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:i="http://schemas.microsoft.com/expression/2010/interactivity"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <UserControl.Resources>
        <Style x:Key="MyAgeStyle" TargetType="{x:Type DataGridCell}">
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="Maroon" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid>
        <DataGrid x:Name="dgEmployee" AutoGenerateColumns="False" ItemsSource="{Binding MyGridData, UpdateSourceTrigger=PropertyChanged}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDoubleClick">
                    <i:InvokeCommandAction Command="{Binding MyAgeCommand}" CommandParameter="{Binding Path=SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Path=IsChecked,Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox IsEnabled="{Binding Path=IsChecked,Mode=TwoWay}" Text="{Binding Name, Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="myAge" Header="Age" Binding="{Binding Age, Mode=TwoWay}" IsReadOnly="True" Width="*" CellStyle="{DynamicResource MyAgeStyle}" />
                <DataGridTextColumn Header="Department" Binding="{Binding Department, Mode=TwoWay}" IsReadOnly="True" Width="*" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
KushMishra 38 Senior Technical Lead

Unfortunately I also cannot find any error in the closing of the tags here. Don't know how exactly should I proceed with this one...!!!

KushMishra 38 Senior Technical Lead

I am not storing my styles anywhere and these are static resources which I am using inside this xaml only.
Also, I am not using any external libraries other than interactivity and interactions and already tried removing the same.
I didn't get what exactly the problem is.
I guess there may be a problem with the DelegateCommand class but I am not sure. Could you please take a look at my DelegateCommand also :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using System.Diagnostics;

namespace MyWPFPracticeApp.GenericClasses
{
    public class DelegateCommand : ICommand
    {
        protected Action<object> _Execute;
        protected Predicate<object> _CanExecute;
        protected EventHandler _CanExecuteChanged = (o, e) => { };

        public DelegateCommand(Action<object> pExecute)
            : this(pExecute, null)
        {
        }
        public DelegateCommand(Action<object> pExecute, Predicate<object> pCanExecute)
        {
            if (pExecute == null)
                throw new ArgumentNullException("pExecute", "[RelayCommand] The action for a command cannot be null.");

            _Execute = pExecute;
            _CanExecute = pCanExecute;
        }
        public bool CanExecute(object pParameter)
        {
            if (_CanExecute != null)
            {
                return _CanExecute(pParameter);
            }
            return true;
        }
        public void Execute(object pParameter)
        {
            _Execute(pParameter);
        }
        public event EventHandler CanExecuteChanged
        {
            add { _CanExecuteChanged += value; }
            remove { _CanExecuteChanged -= value; }
        }
        public void SignalCanExecuteChanged()
        {
            if (_CanExecuteChanged != null)
                _CanExecuteChanged(this, new EventArgs());
        }
    }
}
KushMishra 38 Senior Technical Lead

Sure, here it is...

<UserControl x:Class="MyWPFPracticeApp.Views.MyDataGridResearch"
             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:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             xmlns:interact="clr-namespace:MyWPFPracticeApp.GenericClasses"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <UserControl.Resources>
        <Style x:Key="MyAgeStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
            <EventSetter Event="MouseLeftButtonDown" Handler="{Binding MyAgeCommand}" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <DataGrid x:Name="dgEmployee" AutoGenerateColumns="False" ItemsSource="{Binding MyGridData, UpdateSourceTrigger=PropertyChanged}">
            <DataGrid.Columns>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Path=IsChecked,Mode=TwoWay}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBox IsEnabled="{Binding Path=IsChecked,Mode=TwoWay}" Text="{Binding Name, Mode=TwoWay}"></TextBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn x:Name="myAge" Header="Age" Binding="{Binding Age, Mode=TwoWay}" IsReadOnly="True" Width="*" CellStyle="{StaticResource MyAgeStyle}"/>
                <DataGridTextColumn Header="Department" Binding="{Binding Department, Mode=TwoWay}" IsReadOnly="True" Width="*" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>
KushMishra 38 Senior Technical Lead

Well, actually you need to use some controls like the one you said DataGridView, GridView, DataGrid....You can choose one and start working and if you want to know the difference and their pros-cons you may search the web also to have a clear picture because it all depends on what you intend to do.

I can also suggest you some controls however it would be better that you possibly do a quick analysis on what your requirements are and what purposes they would serve in your application.

I hope you understand what I am trying to convey here :)

KushMishra 38 Senior Technical Lead

Yes, I did but again facing the same issue.

KushMishra 38 Senior Technical Lead

Hi, I tried this approach but this one gave another exception stating..."'XAML Node Stream: Missing EndMember for 'MyWPFPracticeApp.Views.MyDataGridResearch.System.Windows.FrameworkElement.Resources' before EndObject.'"

Here's my style :-

<UserControl.Resources>
   <Style x:Key="MyAgeStyle" TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
      <EventSetter Event="MouseLeftButtonDown" Handler="{Binding MyAgeCommand}" />
   </Style>
</UserControl.Resources>

I am using this style in <DataGridTextColumn x:Name="myAge" Header="Age" Binding="{Binding Age, Mode=TwoWay}" IsReadOnly="True" Width="*" CellStyle="{StaticResource MyAgeStyle}"/> and as you see there is no DataTemplate in this column. Please help if possible.

KushMishra 38 Senior Technical Lead

Ok, another one comes here....
"When a lion is in trouble, even a frog kicks him."

KushMishra 38 Senior Technical Lead

Hi Ketsuekiame, thanks a lot for the reply.
I see Microsoft mentioning that "A NullReferenceException exception occurs when you run a .NET Framework 4.0-based WPF application that has events in a nested template".
However, I don't think I am using a nested template here, but still I am facing the same issue. I am not using any DataTemplates here but still the same exception comes. Anyways I'll try fixing this bug by your help and will surely inform you also :)

KushMishra 38 Senior Technical Lead

Requesting all if anyone could please help me with this :)

KushMishra 38 Senior Technical Lead

So, in my opinion if you want to inter-relate data of 2 or more tables, what you can possibly do is keep a common field like foreign key from 1 table in another.
As per your information provided, I'd recommend you to maintain Customer-Orders relationship and Order-Product relationship...I don't see a use of OrderDeatils table here as you may use a common Order table for both Customer and Product tables but again I cannot recommend you to use this same strategy because it may vary from need to need purposes. I can only suggest you if the same suits your requirements too :)

ddanbe commented: True also +14
KushMishra 38 Senior Technical Lead

Hi, in the SQl Server you may have many tables and columns as per different scenarios.
The data types would all depend on what you intend to store in the table(s).
So I would request you if you could inform about the column names and their purpose so that I can possibly suggest you the data types accordingly.

KushMishra 38 Senior Technical Lead

Hi,

I am developing a WPF application in which I need to call MouseLeftButtonDown event in a single DataGridTextColumn.
For that I wrote some xaml code as :-

<DataGridTextColumn x:Name="myAge" Header="Age" Binding="{Binding Age, Mode=TwoWay}" IsReadOnly="True" Width="*">
    <DataGridTextColumn.CellStyle>
         <Style TargetType="DataGridCell">                            
            <EventSetter Event="MouseLeftButtonDown" Handler="{Binding MyAgeCommand}" />
         </Style>
    </DataGridTextColumn.CellStyle>
</DataGridTextColumn>

But I am getting an "Object reference null" exception. I tried searching this over the Internet however all I found a solution in which I need to refer to an external AttachedCommandBehavior.dll but I don't want to do this.

All I need to ask is some way so that I can bind my Handler to MyAgeCommand as persently, I am unable to do that.

My ViewModel is :-

public DelegateCommand MyAgeCommand
{
    get
    {
       if (_myAgeCommand == null)
           _myAgeCommand = new DelegateCommand(MySelectedCell);
       return _myAgeCommand;
    }
}



private void MySelectedCell(object obj)
{
   // Rest of the code
}
KushMishra 38 Senior Technical Lead

Instead of pidate = timepicker_im.Value.ToString(); write as pidate = timepicker_im.Value.ToShortDateString().

And also, instead of

OpenConCls.nonQuery("INSERT INTO tblpair_individual_membership values('" + idnumber + "','" + fname + "','" + mname + "','" + lname + "','" + email + "','" + cnumber + "','" + expertise + "','" + country + "','" + address + "','" + payment + "','" + status + "','" + timepicker_im.Value.ToString() + "')");

write the following :-

OpenConCls.nonQuery("INSERT INTO tblpair_individual_membership values('" + idnumber + "','" + fname + "','" + mname + "','" + lname + "','" + email + "','" + cnumber + "','" + expertise + "','" + country + "','" + address + "','" + payment + "','" + status + "','" + pidate + "')");
KushMishra 38 Senior Technical Lead

Nice one :)

KushMishra 38 Senior Technical Lead

Get some antivirus program and scan your system and even then if the problem prevails, try re-installing Internet Explorer or simply try to update/upgrade it. I hope that would help :)

KushMishra 38 Senior Technical Lead

Are you using proxy network or VPN by any chance ??

KushMishra 38 Senior Technical Lead

I undersatnd the point you intend to mention over here.
Let me try the your suggestions and I will surely inform you as well over here :)

KushMishra 38 Senior Technical Lead

Unfortunately not however it would be great if you could please let us know about the same :)

KushMishra 38 Senior Technical Lead

I also feel personally that you should try following The Diamonds suggestions

KushMishra 38 Senior Technical Lead

Or another way of soing is to create a class say Contants.cs and store your information into that using properties that would implement get and set

KushMishra 38 Senior Technical Lead

I am sure Fenrir() is absolutely correct for dateTimePicker1.Value.ToShortDateString() as it will trim out the time that is coming into your table present in some database :)

KushMishra 38 Senior Technical Lead

Adding to Cameronsmith63's point, I would rather say that although the overall code syntax remains the same however some classes and namespaces differ as we change from Console to WPF to ASP.Net to any other.
And yes, its all C# or VB mostly in the end (while most of them use other languages too depending upon the requirements).

KushMishra 38 Senior Technical Lead

Hi, there is no ideal expert (perfect, rather) here but what we all can do is share our questions and discuss with each other about any of these above mentioned technologies.
As you start learning these technologies, you may get some questions which you can understand very easily if you go step-by-step and also speaking particularly for myself, I know about these technologies but again I am also not a perfectionist. I have asked many questions here which you may find unreasonable going further. So, best way to discover this fact is to start now...I hope you would agree to the same :)

KushMishra 38 Senior Technical Lead

Good one :)

KushMishra 38 Senior Technical Lead

What I meant to say here was there are several delegate commands syntax available for different purposes. Suppose you have one method as private void MyData() and you are calling it from a Delegate Command while on the other hand I have another method say, private object MyNewData(object obj) being called from the same Delegate Command as yours, so how do I write a generic Delegate Command which can be used for both the methods ?
I tried implementing the same but it allows only a single method either its not void or it is void or it may contain some parameters or not.
In other way round, I am not sure how to write such Delegate Command Class that would achieve a generic functionality for all kinds of methods.

KushMishra 38 Senior Technical Lead

Hi All,

I started developing an application in WPF but I think the generic syntax for Relay Command and Delegate Command cannot be found very easily over the web and hence alogwith asking this question, I intend to start a thread for both Relay Command and Delegate Command.

So, I would request if anyone could please post the generic syntax for Relay Command and Delegate Command and also if possible please explain the differences between the two.

I intend to develop a generic syntax for all the methods (whether they have any return type or void, whether they have parameters passed or are parameter-less), so that anyone can easily find a generic syntax for the same and depending on the usage, can implement the method called through these commands.

Thanks a lot in advance :)