KushMishra 38 Senior Technical Lead

Hi,

I am again stuck at creating dynamic controls i.e., second step in the image at the beginning (upon clicking of the checkbox I need to generate a new combo box with again some check boxes displaying the fields of that selected table) but in ViewModel only.
Below is my current code :-

xaml :-

<UserControl x:Class="MyProjectDemo.View.MultipleDatumFilter"
             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="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"   
              xmlns:interatComm="clr-namespace:InteractivityHelper"
             mc:Ignorable="d" 
             MinHeight="600" MinWidth="800" x:Name="MultipleDatumUC">
    <UserControl.Resources>

    </UserControl.Resources>
    <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <StackPanel>
                <TextBlock x:Name="txtAllTables" Text="Existing Tables" Height="25" Width="150" FontWeight="Bold" />
                <ComboBox x:Name="cmbAllTables" Height="25" Width="175" ItemsSource="{Binding AllTables, UpdateSourceTrigger=PropertyChanged}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Content="{Binding AllTablesCheckBoxContent, UpdateSourceTrigger=PropertyChanged}" IsChecked="{Binding IsAllTablesCheckBoxChecked, Mode=TwoWay}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <interatComm:InteractiveCommand Command="{Binding Path=DataContext.DelegateCmdCheckChange, 
                                    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </CheckBox>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>

ViewModel :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Input;
using System.Windows.Data;
using Microsoft.Practices.Prism.Commands;
using MyProjectDemo.Classes;
using MySql.Data.MySqlClient;
using System.Data;

namespace MyProjectDemo.ViewModel
{
    public class MultipleDatumFilterVM : INotifyPropertyChanged
    {
        #region Fields

        private ObservableCollection<AllTablesCheckbox> _allTables;

        private string _allTablesCheckBoxContent = string.Empty;

        private string _tableSelectedItem = string.Empty;

        private DelegateCommand<RoutedEventArgs> _delegateCmdCheckChange = null;

        #endregion

        #region Public Variables

        public MySqlConnection mySqlCon;

        public CheckBox selectedTableChecked;

        #endregion

        #region Properties

        public ObservableCollection<AllTablesCheckbox> AllTables
        {
            get { return _allTables; }
            set
            {
                _allTables = value;
                OnPropertyChanged("AllTables");
            }
        }

        public string AllTablesCheckBoxContent
        {
            get { return _allTablesCheckBoxContent; }
            set
            {
                _allTablesCheckBoxContent = value;
                OnPropertyChanged("AllTablesCheckBoxContent");
            }
        }

        public string TableSelectedItem
        {
            get { return _tableSelectedItem; }
            set
            {
                _tableSelectedItem …
KushMishra 38 Senior Technical Lead

I already tried these things out however I have done this by removing the class member "IsAllTablesCheckBoxChecked", taking data template of checkbox inside the comobobox and adding an Event Trigger by calling a dependency property that I discussed about in the previous article and my final code is up and running.
My code is as follows :-

xaml :-

<UserControl x:Class="MyProjectDemo.View.MultipleDatumFilter"
             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="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"   
             xmlns:interatComm="clr-namespace:InteractivityHelper"
             mc:Ignorable="d" 
             MinHeight="600" MinWidth="800">
    <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <StackPanel>
                <TextBlock x:Name="txtAllTables" Text="Existing Tables" Height="25" Width="150" FontWeight="Bold" />
                <ComboBox x:Name="cmbAllTables" Height="25" Width="175" ItemsSource="{Binding AllTables, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedTableContents, UpdateSourceTrigger=PropertyChanged}">

                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <interatComm:InteractiveCommand Command="{Binding DelegateCmdCheckChange}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>

                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <CheckBox Content="{Binding AllTablesCheckBoxContent, UpdateSourceTrigger=PropertyChanged}" IsChecked="{Binding IsAllTablesCheckBoxChecked, Mode=TwoWay}">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <interatComm:InteractiveCommand Command="{Binding Path=DataContext.DelegateCmdCheckChange, 
                                    RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ComboBox}}}" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </CheckBox>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>

View Model :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Input;
using System.Windows.Data;
using Microsoft.Practices.Prism.Commands;
using MyProjectDemo.Classes;
using MySql.Data.MySqlClient;
using System.Data;

namespace MyProjectDemo.ViewModel
{
    public class MultipleDatumFilterVM : INotifyPropertyChanged
    {
        #region Fields

        private ObservableCollection<AllTablesCheckbox> _allTables;

        private string _allTablesCheckBoxContent = string.Empty;

        private string _tableSelectedItem = string.Empty;

        private string _selectedTableContents = string.Empty;

        private DelegateCommand<RoutedEventArgs> _DelegateCmdCheckChange = null;

        #endregion

        #region Public Variables

        public MySqlConnection mySqlCon;

        public CheckBox selectedTableChecked;

        #endregion

        #region Properties

        public ObservableCollection<AllTablesCheckbox> AllTables
        {
            get { return _allTables; }
            set
            {
                _allTables = value;
                OnPropertyChanged("AllTables");
            }
        }

        public string AllTablesCheckBoxContent
        {
            get { return _allTablesCheckBoxContent; }
            set …
KushMishra 38 Senior Technical Lead

Hi,

Could you please see the following code :-

For xaml :-

<UserControl.Resources>
        <DataTemplate x:Key="chkBoxTemplate">
            <CheckBox Content="{Binding AllTablesCheckBoxContent, UpdateSourceTrigger=PropertyChanged}" IsChecked="{Binding IsTableChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <StackPanel>
                <TextBlock x:Name="txtAllTables" Text="Existing Tables" Height="25" Width="150" FontWeight="Bold" />
                <ComboBox x:Name="cmbAllTables" Height="25" Width="175" ItemTemplate="{StaticResource chkBoxTemplate}" ItemsSource="{Binding AllTables, UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>

For ViewModel :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Input;
using System.Windows.Data;
using Microsoft.Practices.Prism.Commands;
using MyProjectDemo.Classes;
using MySql.Data.MySqlClient;
using System.Data;

namespace MyProjectDemo.ViewModel
{
    public class MultipleDatumFilterVM : INotifyPropertyChanged
    {
        #region Fields

        private ObservableCollection<AllTablesCheckbox> _allTables;

        private bool _isTableChecked = false;

        #endregion

        #region Public Variables

        public MySqlConnection mySqlCon;

        #endregion

        #region Properties

        public ObservableCollection<AllTablesCheckbox> AllTables
        {
            get { return _allTables; }
            set
            {
                _allTables = value;
                OnPropertyChanged("AllTables");
            }
        }

        public bool IsTableChecked
        {
            get { return _isTableChecked; }
            set
            {
                _isTableChecked = value;
                OnPropertyChanged("IsTableChecked");
            }
        }

        #endregion

        #region Commands

        #endregion

        #region Constructors

        public MultipleDatumFilterVM()
        {
            mySqlCon = new MySqlConnection("Server=127.0.0.1; Database=test; Uid=root");
            ListTables();
        }

        #endregion

        #region Private Methods

        private void ListTables()
        {
            try
            {
                mySqlCon.Open();
                List<string> tables = new List<string>();
                _allTables = new ObservableCollection<AllTablesCheckbox>();
                AllTablesCheckbox allTablesCheckbox = new AllTablesCheckbox();
                DataTable dt = mySqlCon.GetSchema("Tables");
                foreach (DataRow row in dt.Rows)
                {
                    string tablename = (string)row[2];
                    tables.Add(tablename);
                }
                foreach (var item in tables)
                {
                    _allTables.Add(new AllTablesCheckbox() { AllTablesCheckBoxContent = item, IsAllTablesCheckBoxChecked = IsTableChecked });
                }
                mySqlCon.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        #endregion

        #region OnPropertyChangedEvent

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged; …
KushMishra 38 Senior Technical Lead

Thanks a lot for your reply.
I have taken help from your code and added some new methods and class and its working fine now for me.

KushMishra 38 Senior Technical Lead

Hi All,

I am working on a page that creates a dynamic MySql query with the selected fields at the run time and for this I want to take a combobox with few checkboxes so that based on their selection I can fetch the query result and populate them into the datagrid.
And also the most important thing I forgot to mention is that I want to achieve these functionalities in the ViewModel (VM) class only and if one could use templates for these comboboxes that would be an extra advantage.
Please see the screenshot below for the functionality module I want to achieve as of now. 94c5842ce31bfd8fb6f367bf0a6ba40d
Any help is highly appreciated.
Thanks :)

KushMishra 38 Senior Technical Lead

I don't think that the framework will be confused by double registration because we already have Command and CommandParameter defined for buttons and other controls.
How about viewing the existing Command and CommandParameter properties. Can we see them how they are defined as I am not sure about this one ?

KushMishra 38 Senior Technical Lead

Actually I didn't have ComboBox in my xaml but anyways I set the property of that object in the code behind as IsEnabled="false" and that worked.

Thanks for your time and replies..much appreciated.

KushMishra 38 Senior Technical Lead

Thanks a lot Ketsuekiame,

However I am populating these things in a combobox with headings and I want to make this header text non-selectable in the combobox like we do using GroupStyle...How can I achieve this ?

KushMishra 38 Senior Technical Lead

Hi All,

I am creating a dynamic GroupBox through C# and want to change only the header font and not all the fonts in that.

GroupBox myGroupBox = new GroupBox();
myGroupBox.Header = mychk.Content.ToString();
myGroupBox.Content = myStack;

Here, myGroupBox.FontWeight changes all the contents inside the myGroupBox but how to change only the header font of this myGroupBox ?

KushMishra 38 Senior Technical Lead

Thanks for your quick response and following your suggestion I replaced the UIPropertyMetadata with FrameworkPropertyMetadata however how can it register if I comment out the following code ?

public static readonly DependencyProperty CommandParameterProperty =
            DependencyProperty.Register("CommandParameter", typeof(ICommand), typeof(InteractiveCommand), new FrameworkPropertyMetadata(null));

Also, correct me if I am wrong, to use a dependency property we must register it so if I don't register how will I be able to access the CommandParameter property ?
Could you please provide some code snippet as an example?

KushMishra 38 Senior Technical Lead

Thanks a lot Ketsuekiame for your reply...Really appreciate this one.
Actually, I want to pass a UIElement Control (like x:Name/Name) in any of the events of a second control which does not support Command and CommandParameter as its properties (like TextBlock).
We have the following scenario :-

<Button Command="{Binding SomeCommand}" CommandParameter="{Binding ElementName=SomeControlName}" />

But we cannot have the same thing in a TextBlock and so to make it support I created this class with 2 dependency properties and used in my xaml like :-

<TextBlock>
 <i:Interaction.Triggers>
   <i:EventTrigger EventName="KeyDown">
      <interatComm:InteractiveCommand Command="{Binding DelegateCommandKey}" CommandParameter"{myDataGrid}" />
   </i:EventTrigger>
 </i:Interaction.Triggers>
</TextBlock>

But here at run time, I observed that the "Command" property is working perfectly fine like the default Command property present in the "Button" control whereas I caanot have the CommandParameter doing its job.

I may have written some incomplete code for the dependency property as I made such a property the first time due to which I am requesting that if anyone could possibly update that what exactly the code should be for the "CommandParameter" inside the dependency class or how do I need to proceed further.

KushMishra 38 Senior Technical Lead

Hi pritaeas,

The "Command" property is working fine but the "CommandParameter" is not working i.e., I can pass the events of the controls to the classes however I cannot pass the parameters that would be used in those events and thats where I am stuck and also, I have already mentioned what I need to do by creating these dependency properties, so please go through the first post and if possible please suggest any help for the same.

KushMishra 38 Senior Technical Lead

Hi,

You may try creating an object of the first window in the second window and then try accessing the grid in first window from second window by using

var myGrid = objectOfFirstWindow.FindName("gridNameOrIDInFirstWindow") as Grid;

Hope that helps :)

KushMishra 38 Senior Technical Lead

So, you're saying I am getting pissed off when I am not getting answer/reply to my post and you expect me to appreciate your kind concern of suggesting alternatives, making comments and behaving like a frustrated Admin from my replies and you think its very nice of you to suggest alternatives to people asking for help and telling them that "you are getting pissed off Mr., why are you anyways here expecting for replies as there are still none".
I wonder who has made you the Admin of this site and of course I must commit that I am angry but its not getting in the way of my rational thoughts because still I am speaking logic and not getting pissed off with replies and telling people that "Mr. I am a professionally well mannered helpful admin but you...hey you are getting pissed off...!!!".
Thanks man.

KushMishra 38 Senior Technical Lead

Yeah well nobody has bothered to reply and I guess someone has send you to comment on this as no one has even bothered to reply...!!!
One side you're saying 6 days is a long time and on the other you said that I'm nagging for replies because I was not getting them fast enough (Are you even sure about what you are saying ???)
I never said that Daniweb offers any guarantee (3 years is a long time to understand that) and of course I'll search for alternatives as well after your kind reply...!!!
So, is this the way we all should go over this community meant for supporting people in the areas where they've got their expertise and you would tend towards no longer expecting an answer ???

KushMishra 38 Senior Technical Lead

Great, there are no replies still and I receive your comment not to bump my posts...So dear deceptikon, would you please tell me if there are no replies (like the previous 4 posts of WPF from me), what exactly I should be doing instead of asking help from someone ???
I joined this community 3 years ago and now you're telling me that clearly there are no replies....Well if there were no replies that's why I was waiting for the same...Being an Administrator does not mean that you critisize someone who asks for help (clearly that's why we're all here to help and ask for support).
Thanks again for no replies and commenting instead...!!!

KushMishra 38 Senior Technical Lead

Any replies ???

KushMishra 38 Senior Technical Lead

Any replies ???

KushMishra 38 Senior Technical Lead

Any replies ???

KushMishra 38 Senior Technical Lead

Can anyone please reply ???

KushMishra 38 Senior Technical Lead

You have given ";" after num and that means the end of statement, so it throws an error for "i" and "sum".
Try using

int num, i = 0, sum = 0;

Hope that helps.

KushMishra 38 Senior Technical Lead

Your namespace should match with the name of your C# project name.
Is "venkat" your project name and if not try changing "venkat" to the name of your project (not the solution).

KushMishra 38 Senior Technical Lead

Hi,

Have you tried using DataGridRow instead of using DataGrid ?
Because I think what you need is for the particular DataGridRow, so if you would get the particular DataGridRow then it would be easy to find the element (TextBlock in your case) in that cell and changing its value...
May be you can try using and editing the following code :-

DependencyObject depObj = (DependencyObject)(e.OriginalSource);
                    if (depObj != null)
                    {
                        for (int i = 0; i < VisualTreeHelper.GetChildrenCount(depObj); i++)
                        {
                            var child = VisualTreeHelper.GetChild(depObj, i);
                            while ((child != null) && !(child is DataGridRow))
                            {
                                child = VisualTreeHelper.GetParent(child);
                            }

                            if (child is DataGridRow)
                            {
                                DataGridRow a = (DataGridRow)child;

                                // Your functionality but not this exactly
                                // TextBlock.Text= ComboBox.SelectedItem;
                            }
                        }
                    }

Hope that may help you :)

KushMishra 38 Senior Technical Lead

You need to have a method in the KeyDown event of the textbox like say :-

private void CallKeyDown(object sender, KeyEventArgs e)
{
    if(e.Key==Key.Return)
    {
      // Your Search Functionality
    }
}

Hope that helps :)

KushMishra 38 Senior Technical Lead

I think its the problem your keyboard is making...Have you tried running the application and then pressing the "Insert" key and then typing again ?

KushMishra 38 Senior Technical Lead

Hello All,

I want to create a combobox of Countries with 3 Group Headers as "Favourites", "Frequently Used" and "Rest of the world".
I am not sure how to achieve the favourites and frequently used functionality.
I have written some sample code that runs fine but the real functionality for favourites and frequently used is missing.
Please help me on this and kindly update on how to achieve the same.
My sample code is as follows :-

 <ComboBox x:Name="cmbCountry" DisplayMemberPath="Item" Height="25" Width="200" HorizontalAlignment="Center" VerticalAlignment="Center">
            <ComboBox.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12"/>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ComboBox.GroupStyle>
        </ComboBox>

And....

public partial class CountryUC : UserControl
    {
        public CountryUC()
        {
            InitializeComponent();
            DataContext = this;

            List<CategoryItem<string>> items = new List<CategoryItem<string>>();

            items.Add(new CategoryItem<string> { Category = "----- Favourites -----", Item = "India" });
            items.Add(new CategoryItem<string> { Category = "----- Favourites -----", Item = "Germany" });
            items.Add(new CategoryItem<string> { Category = "----- Frequently Used -----", Item = "United States" });
            items.Add(new CategoryItem<string> { Category = "----- Frequently Used -----", Item = "United Kingdom" });
            items.Add(new CategoryItem<string> { Category = "----- Rest of the world -----", Item = "Australia" });
            items.Add(new CategoryItem<string> { Category = "----- Rest of the world -----", Item = "Canada" });

            //Need the list to be ordered by the category or you might get repeating categories
            ListCollectionView lcv = new ListCollectionView(items.OrderBy(w => w.Category).ToList());

            //Create a group description
            lcv.GroupDescriptions.Add(new PropertyGroupDescription("Category"));

            cmbCountry.ItemsSource = lcv;
        }
    }
    public class CategoryItem<T>
    {
        public T Item { …
KushMishra 38 Senior Technical Lead

Thanks again for no replies...!!!

KushMishra 38 Senior Technical Lead

Hi,

I want to create a dependency property for both Command and CommandParameter so that I can use these in controls that don't support Command and CommandParameter like textblock etc.
I have written and taken help from someone to create DP(dependency property) for Command and its working fine but for CommandParameter, I am not sure how to proceed.
My Code is as follows :-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Interactivity;
using System.Windows;
using System.Windows.Input;
using System.Reflection;
using System.Windows.Controls;

namespace InteractivityHelper
{
    public class InteractiveCommand : TriggerAction<DependencyObject>
    {
        protected override void Invoke(object parameter)
        {
            if (base.AssociatedObject != null)
            {
                ICommand command = this.ResolveCommand();
                if ((command != null) && command.CanExecute(parameter))
                {
                    command.Execute(parameter);
                }
            }
        }

        private ICommand ResolveCommand()
        {
            ICommand command = null;
            if (this.Command != null)
            {
                return this.Command;
            }
            if (base.AssociatedObject != null)
            {
                foreach (PropertyInfo info in base.AssociatedObject.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                {
                    if (typeof(ICommand).IsAssignableFrom(info.PropertyType) && string.Equals(info.Name, this.CommandName, StringComparison.Ordinal))
                    {
                        command = (ICommand)info.GetValue(base.AssociatedObject, null);
                    }
                }
            }
            return command;
        }

        private string _commandName;

        public string CommandName
        {
            get
            {
                base.ReadPreamble();
                return this._commandName;
            }
            set
            {
                if (this.CommandName != value)
                {
                    base.WritePreamble();
                    this._commandName = value;
                    base.WritePostscript();
                }
            }
        }

        #region Command

        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValue(CommandProperty, value); }
        }

        public ICommand CommandParameter
        {
            get { return (ICommand)GetValue(CommandParameterProperty); }
            set { SetValue(CommandParameterProperty, value); }
        }

        public static readonly DependencyProperty CommandProperty =
            DependencyProperty.Register("Command", typeof(ICommand), typeof(InteractiveCommand), new UIPropertyMetadata(null));

        public static readonly DependencyProperty CommandParameterProperty =
            DependencyProperty.Register("CommandParameter", typeof(ICommand), typeof(InteractiveCommand), new UIPropertyMetadata(null));

        #endregion
    } …
KushMishra 38 Senior Technical Lead

Thanks for no answer...!!!

KushMishra 38 Senior Technical Lead

Hi,

I found the solution on my own but thanks for the suggestions anyways, they may help me in the future :)

KushMishra 38 Senior Technical Lead

Hello All,

I want to add a functionality to my WPF usercontrol in the Head section like the image below :-

f4418c3ccc7f9a4d7f30aee9903987c6

Could someone please suggest some approach on how to achieve the same ?

KushMishra 38 Senior Technical Lead

Dear All,

I am using Visual Studio 2012 and created a WPF application.
I just want to know that how to include pre-requisites like set up files of .Net framework etc. in my setup project so that if anyone installing my setup has not got the framework installed on his/her system then the software installer automatically installs that framework from a local path present in my setup folder.

I did the same in Visual Studio 2010 many times but the Installer Shield Limited Edition changed many things.

Please help me with this.

KushMishra 38 Senior Technical Lead

Can someone please help me ???

KushMishra 38 Senior Technical Lead

I am done with the expander and edit button functionalities (point numbers 1 and 3) however I'm still struggling with the checkbox thing. Could someone please help me out of this ?

KushMishra 38 Senior Technical Lead

hi Ketsuekiame,

Could you please ellaborate by giving some code snippets or adding to my code ?

KushMishra 38 Senior Technical Lead

Dear All,

I have written some logic using MVVM pattern and tried to show a sub-datagrid in each row of a datagrid however there are some issues that I am currently facing and they are as follows (screenshot attached) :-

  1. In each row I have an expander in which I want to control the RowDetailsVisibilityMode of my sub datagrid.

  2. For selected checkboxes the rows should be deleted when clicked on Delete button at the end.

  3. Upon clicking of the Edit button, one can edit a particular row and again the rows become readonly.

Please suggest some approach on how to do this and kindly find my code as follows :-

View :-

<UserControl x:Class="WIMOProjectDemo.View.CustomerManagementModule"
             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:km="clr-namespace:WIMOProjectDemo.ViewModel"
             xmlns:prop="clr-namespace:WIMOProjectDemo.Properties"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:interatComm="clr-namespace:InteractivityHelper"
             mc:Ignorable="d" 
             MinHeight="400" MinWidth="600">
    <UserControl.DataContext>
        <km:CustomerManagementModuleVM></km:CustomerManagementModuleVM>
    </UserControl.DataContext>
    <UserControl.Resources>
        <DataTemplate x:Key="SubGridData">
            <TabControl Width="Auto" Height="Auto" Margin="50,0,0,0">
                <TabItem Header="Other Contacts">
                    <DataGrid Width="Auto" Height="Auto" Background="AliceBlue" ItemsSource="{Binding SubGridData}" 
                              GridLinesVisibility="None">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Name" Binding="{Binding Path=Name}" />
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Email" Binding="{Binding Path=Email}" />
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Phone" Binding="{Binding Path=Phone}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem>
                <TabItem Header="Billing Address">
                    <TextBlock Text="This is Billing Address" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </TabItem>
                <TabItem Header="Delivery Address">
                    <DataGrid Width="Auto" Height="Auto" Background="DarkGoldenrod" ItemsSource="{Binding SubGridData}" 
                              GridLinesVisibility="None" >
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Name" Binding="{Binding Path=Name}" />
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Email" Binding="{Binding Path=Email}" />
                            <DataGridTextColumn Width="60" IsReadOnly="True" Header="Phone" Binding="{Binding Path=Phone}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem>
                <TabItem Header="Other Information">
                    <TextBlock Text="This is Other Information" HorizontalAlignment="Center" VerticalAlignment="Center" />
                </TabItem>
            </TabControl>

        </DataTemplate>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.10*"/>
            <RowDefinition Height="0.02*"/>
            <RowDefinition …
KushMishra 38 Senior Technical Lead

Hello All,

I intend to develope a console application in C# in which there should be 3 functionalities :-

  1. Open Wordpad.exe and automatically type something.
  2. Save the updated document.
  3. Close the Wordpad with changes saved.

Kindly guide me if anyone has some ideas. I have managed to open Wordpad but rest I am not so sure. So please tell me the exact approach or the needful.

KushMishra 38 Senior Technical Lead

Thanks a lot to all...I have found a solution :)
http://stackoverflow.com/questions/771275/resizing-a-control-in-wpf

KushMishra 38 Senior Technical Lead

Hi Ketsuekiame,

Thanks for your reply.
You may be aware of the different shapes we can draw in MS Power point like Rectangle, Pie chart, Circle etc. however I want to do the same thing along with rotation, resizing and dragging controls at run time.
If possible, could you please help and direct me how to achieve this?

KushMishra 38 Senior Technical Lead

Any replies guys please as it is real urgent ???

KushMishra 38 Senior Technical Lead

Hi all,

I want to develop a pie chart with functionality of dragging and resizing but not like a fixed size.
Initially it should come as a quater sized and should be ressizable to any angle just like done with the MS power point.

Any idea to kick start this one would be really appreciated.

Thanks a lot in advance.

KushMishra 38 Senior Technical Lead

Is there anyone who could possibly answer ?

KushMishra 38 Senior Technical Lead

Can anyone please tell me about this ???

KushMishra 38 Senior Technical Lead

Hi all,

I have searched different websites about data binding in Silverlight however could anyone please tell me what exactly is Binding and why we use it and if we don't use binding, is there any alternative to that ?

Thanks in advance.

KushMishra 38 Senior Technical Lead

Thanks a lot LastMitch, I changed the resource dictionary path as I think that it only takes the relative path but not the absolute one.
Now its working fine....Thanks again.

KushMishra 38 Senior Technical Lead

Hi all,

I have a resource dictionary which is already added to the App.xaml however when I add the particular style to my Grid, it doesn't gets reflected while debugging.
Can anyone please help me on this ?
My codes are as follow :-

MainPage.xaml

<Grid x:Name="myGrid_MainPage" Style="{StaticResource myGridStyle}">

myRD_Main.xaml

<Style x:Key="myGridStyle" TargetType="Grid">
    <Setter Property="Grid.Background">
        <Setter.Value>
            <LinearGradientBrush>
                <GradientStopCollection>
                    <GradientStop Color="Red" Offset="0.5"></GradientStop>
                    <GradientStop Color="Black" Offset="0.5"></GradientStop>
                </GradientStopCollection>
            </LinearGradientBrush>
        </Setter.Value>
    </Setter>
</Style>

App.xaml

 <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="C:\Users\MyUser\documents\visual studio 2010\Projects\mySilverlight_App_Practice\mySilverlight_App_Practice\myResources\myRD_Main.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
KushMishra 38 Senior Technical Lead

Thanks for no help anyways I've found a solution on my own.

nmaillet commented: Quit whining. +0
KushMishra 38 Senior Technical Lead

Is there no one to help me ???

KushMishra 38 Senior Technical Lead

Please help me someone.

Thanks a lot in advance.

KushMishra 38 Senior Technical Lead

Hello all,

I have an application in which I have put a datagrid with update and delete buttons.
What I want is when I change the contents of the columns and click on update button, it should update that particular cell value into the database.

My xaml code is as follows :-

<UserControl x:Class="Petroweb_WPF_App.Petroweb_UserControls.Petroweb_ManageUploads"
             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" 
             d:DesignHeight="600" d:DesignWidth="800" xmlns:my="clr-namespace:Petroweb_WPF_App.Petroweb_UserControls" HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid Height="Auto" Width="Auto">
        <DataGrid x:Name="PetroManageGrid" AutoGenerateColumns="False" ColumnWidth="*" AlternatingRowBackground="Transparent" RowBackground="Transparent">
            <DataGrid.Columns>
                <DataGridTextColumn x:Name="FName" Binding="{Binding FileName}" Width="150" Header="File Name"></DataGridTextColumn>
                <DataGridTextColumn x:Name="FPath" Binding="{Binding FilePath}" Width="450" Header="File Path"></DataGridTextColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Update" x:Name="UpdateB" Width="100" Click="UpdateB_Click"></Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Delete" x:Name="DeleteB" Width="100" Click="DeleteB_Click"></Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>

Please help someone.
Thanks a lot.