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

moving rectangles in WPF, Errors.

$
0
0

I am attempting to move rectangles in WPF inside the program while the program is running

I have:

leftrec.SetValue(Canvas.TopProperty, lefthand.Y);

Throws an "Argumentexception was unhandled" error, saying that "893 (among other values it's given me over the course of several debuggings) is not a valid value of property "Top"

my canvas is 1280 x 960....

Im stumped as to how to fix this.

                      


How do you insert text,table and images in a wpf richtextbox document where the caret is positioned?

$
0
0
How do you insert text,table and images in a wpf richtextbox document where the caret is positioned?

ClickCount stuck at 1 with .MouseUp event

$
0
0

This question might be little stupid but couldn't find the right words to search google to know the answer.

The problem is, when i go the MouseButtonEventArgs e.ClickCount, which was added to a image.MouseUp. Its always stays at 1. No matter how fast i click.

But keeping the logic same, if i just add the same event to image.MouseDown, its changes value accordingly. 

What does this mean?

C# - Extend Glass Frame

$
0
0
Helllo Everyone :)
Patric Scribe gived me a few days ago this link about Extand Glass Frame Into WPF Application.
I have been trying to expand the glass efact to all my window background but with not success.
I couldn'tunderstand how to Exptend  the glass frame with msdn tutorial, so I hope somone could help me to understed this.
Thanks alot to the helpers :)



---N.M.---


P.S
Sorry about my English :)


Using alternative InputGesture (Key Mapping) for RoutedUICommand/ApplicationCommands

$
0
0

I have implemented a WPF ApplicationsCommand.New and thought it would be a clever idea to implement alternative scenarios with the same command - just using different parameters from an enumeration for doing different things.

<MenuItem Header="{x:Static cmdLabel:Strings.STR_CmdName_New_Text}"
Command="New"
CommandParameter="{x:Static vm:TypeOfDocument.EdiTextEditor}"
ToolTip="{x:Static cmdLabel:Strings.STR_CmdName_New_Text_TT}"
ToolTipService.ShowOnDisabled="True" /><MenuItem Header="{x:Static cmdLabel:Strings.STR_CmdName_New_UML}"
Command="New"
CommandParameter="{x:Static vm:TypeOfDocument.UMLEditor}"
ToolTip="{x:Static cmdLabel:Strings.STR_CmdName_New_UML_TT}"
ToolTipService.ShowOnDisabled="True" />

see h t t p s : / /edi.codeplex.com/SourceControl/latest#Edi/View/MainMenu.xaml

My Command definition is the standard that WPF has predefined. I simply bind the implementation to ApplicationsCommand.New without changing any gestures. The result is that I have two menu entries and both are listed with CTRL+N.

In my case, I want to create a new:

- text document with CTRL+N or
- a new UML document with CTRL+N,U

Is there a way to resolve this with ApplicationsCommand.New?

What about RoutedUICommands? Is it possible to recycle the same RoutedUICommand in multiple places, using different parameters and different keyboard shortcuts?

Thanks for any help on this as I was unable to resolve this on my own :-(


Knowing what is unselected

$
0
0

How can I know which element is unselected?

<ListBox Grid.Column="1" x:Name="Territories" SelectionMode="Single" cal:Message.Attach="[Event SelectionChanged] = [Action terrSelChanged(Territories.SelectedItem)]" ><ListBox.ItemTemplate><DataTemplate><CheckBox IsChecked="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}, Path=IsSelected}" Content="{Binding TerrText}"/> <!-- cal:Message.Attach="[Event Click] = [Action terrSelChanged(Territories.SelectedItem)]"/ --></DataTemplate></ListBox.ItemTemplate></ListBox>


----

    class TerrSel : PropertyChangedBase
    {
        public string TerrText { get; set; }
        public string TerrID { get; set; }
        public bool IsSelected { get; set; }
    }


    public void terrSelChanged(TerrSel terr)
    {
        int terrs = 0;

        Console.WriteLine("Territory: " + terr.TerrText);
        terr.IsSelected = true;
    }

I can select the entities and if I use SelectionMode="Single" I can get tje item or index of the selected entity, but if I unselect it, I get null as an entity or -1 as the index.

I know something is unselected, but which?

DragDrop Adorner Template disappears between windows

$
0
0

Hi,

I'm having an issue where my drag drop adorner template is disappearing when dragging from one window to another. The drop performs perfectly correctly but the adorner template is only visable in the window where you stat. As soon as you get to the edge of the window is begins to get clipped. This is dragging from a datagrid in one window to another datagrid in another window. Seems ok as long as the datagrids are in the same window. Is there any way around this?

Regards

Celestrium

How to use navigation inside a tab control

$
0
0

Hello,

I'm working on a simple communications program that uses a tabbed document interface. Each tab represents a connection to the outside world. Inside the tab, there is a view for the configuration options and a button "Connect". When the user enters relevant details and connects, I want to move to a different view that the user can interact with the remote terminal.

How do I embed navigation controls in the TabControl.Content? Once the user has connected, pressing back will go to the settings (for reference only), forward will then show the actual connection. If disconnected, the user should be able to switch between the two pages independently. Likewise, if there's a disconnect from the remote side, they can click "back" and reconnect without having to setup a new connection. Sounds ideal for the NavigationWindow!

The following is the root window and gives an idea of what I want to do.

<Window x:Class="InetClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:v="clr-namespace:InetClient.View"
        xmlns:vm="clr-namespace:InetClient.ViewModel"
        Title="MainWindow" Height="350" Width="525" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
        MinWidth="400" MinHeight="330" ResizeMode="CanResizeWithGrip"><Window.DataContext><vm:InetClientViewModel x:Name="viewModel"/></Window.DataContext>

  ...

  <Grid Margin="5,5,5,5"><TabControl x:Name="tabConnections"
                IsSynchronizedWithCurrentItem="True"
                ItemsSource="{Binding Path=Connections}"><TabControl.ItemTemplate>
        ...</TabControl.ItemTemplate><TabControl.ContentTemplate><DataTemplate><!-- HOW TO SET UP NAVIGATION FOR TWO USERCONTROLS
               HERE? --><v:ConnectionView/></DataTemplate></TabControl.ContentTemplate></TabControl></Grid>

  ...
</Window>

Do I need to set up NavigationWindow as the root (this is the window that's loaded), But then I want the controls to be inside the tab control itself. Setting up a frame and setting the source to pack://application:,,,/Views/ConnectionView.xaml or using<Frame><Frame.Source><v:ConnectionView/></Frame.Source></Frame> raises an error that the control isn't supported in a frame.

This is my first WPF application and I've already solved a number of MVVM problems, so any links for further information will be greatly appreciated.

Thanks,
Jason.




Add table to repeating pages flowdocument

$
0
0

Hello,

I am trying to add a table to start on every page before flowdocument starts to print or as a header. I have put the code of the table below.

Please help. All I want to do is to put this table when a page begins on each page. Please help with a Paginator which includes this table as a header please or an example.

Thank you in advance.

 Table table2 = new Table();
                table2.FontFamily = new System.Windows.Media.FontFamily("Arial");
                table2.CellSpacing = 0;
                // table1.Padding = ;
                table2.BorderBrush = System.Windows.Media.Brushes.LightGray;
                table2.BorderThickness = new Thickness(0, 0.5, 0, 0.5);
                int numberOfColumnvs = 9;
                for (int x = 0; x < numberOfColumnvs; x++)
                {
                    table2.Columns.Add(new TableColumn());
                    table2.Columns.Add(new TableColumn() { Width = GridLength.Auto });

                }
                // Create and add an empty TableRowGroup to hold the table's Rows.
                table2.RowGroups.Add(new TableRowGroup());

                // Add the first (title) row.
                //table1.RowGroups[0].Rows.Add(new TableRow());

                // Alias the current working row for easy reference.
                table2.RowGroups[0].Rows.Add(new TableRow());
                TableRow currentRow2 = table2.RowGroups[0].Rows[0];

                int t2df = (from b in conn.tblReQResults
                            where b.ResultID == GlobalVariables.ResultID && b.Result != "" && b.tblTestPram.tblSubTest.tblPanel.tblCategory.CatID == ynb.CatID
                            select b).Count();
                if (t2df != 0)
                {
                    table2.RowGroups[0].Rows.Add(new TableRow());
                    currentRow2 = table2.RowGroups[0].Rows[0];

                    currentRow2.Cells.Add(new TableCell(new Paragraph(new Run(ynb.Category))));
                    currentRow2.Cells[0].TextAlignment = TextAlignment.Center;
                    currentRow2.Cells[0].FontSize = 12;
                    currentRow2.Cells[0].FontWeight = System.Windows.FontWeights.Bold;
                    currentRow2.Cells[0].BorderThickness = new Thickness(0, 0, 0, 0.5);
                    currentRow2.Cells[0].BorderBrush = System.Windows.Media.Brushes.LightGray;
                    currentRow2.Cells[0].ColumnSpan = 9;
                    conn = new AtaLIMSDataContext();
                    section.Blocks.Add(table2);

}

Prevent parent control selection/deselection

$
0
0

I have a child control that handles mouseLeftButtonDown event. When I perform CTRL+click it executes code logic to select data in my chart. However, it's parent control gets deselected too. How can I prevent this? I used the e.Handled = true; but no luck. Thanks!

private void Chart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)        
{                         
   if (Keyboard.Modifiers == ModifierKeys.Control)           {
       //select data             
   }                            
}

Is WPF dead or going to be

RenderTargetBitmap() Out of Memory Exception

$
0
0

Hi All,

I am using RenderTargetBitmap() function in a loop. I am facing out of memory exception when I execute the function. Below is the function which I use.

Out Of memory exception

Any help will be highly appreciated...

Thanks,

Ajit

Setting Container Position in WPF

$
0
0

Hi

I want to show a container in WPF application at a specified point. How can i do that ?

The window contains a Webbrowser control and i want to show a custom section ( may be a grid or Stackpanel with few buttons )  on the top of the webbrowser at some specific cordinates based on the position of selected text in webbrowser control.

My window structure is like

<Grid name="container">

<WebbRowser />

<stackpanel name="customactions" visibility="collapsed">

</Grid>

What i am doing is on selection change event of webbrowser control change visibility of customactions (Now its showing exactly on center of web browser ). BUt if i know the x,y cordinates value , how can i set the position of the custommenu ?


Thanks ***Share Knowledge to gain more***

File dialog positioned behind the parent window

$
0
0

Hi,

I have made a reference of “ApplicationClass” which is in “Microsoft.Office.Interop.Excel” namespace. As I call the Save() method of this class, the SaveAs dialog appears but it goes behind the application. I want this dialog always at the Front of all the opened applications. How to achieve this?

Warm regards,

john

How to retrieve which dynamically generated combobox has been selected inside dynamically generated Groupbox

$
0
0

I am a C++ developer and recently started working on WPF. I am sorry for the weird title since I wasnt sure what to put. In my app, I need to dynamically generate 2 groupboxes which contain buttons, labels, textbox, combobox's and so on. And once its done, I need to perform some operation on these controls.

I have 2 xaml files PCMGenView.xaml and PCMGenWidgetView.xaml wherePCMGenWidgetView.xaml file has the groupbox and is added to the PCMGenView.xaml file. I also have 2 viewmodel classes and a model class. Well let me show you how I have done it:

PCMGenView.xaml

<UserControl.Resources><DataTemplate x:Key="PGenDataTemplate"><WrapPanel><TextBlock Text="{Binding Description}" Margin="5,5,0,0"/><local:PCMGenWidgetView Margin="5,10,5,5"/></WrapPanel></DataTemplate></UserControl.Resources><Grid><ItemsControl ItemTemplate="{StaticResource PGenDataTemplate}" ItemsSource="{Binding PGenWidgets}"><ItemsControl.ItemsPanel><ItemsPanelTemplate><WrapPanel /></ItemsPanelTemplate></ItemsControl.ItemsPanel></ItemsControl></Grid>

PCMGenWidgetView.xaml:

<Grid><GroupBox Height="Auto" HorizontalAlignment="Stretch" Margin="10" Name="groupBox1" VerticalAlignment="Stretch" Width="Auto"><Grid ><ComboBox Grid.Column="1" ItemsSource="{Binding PreScalarList}" SelectedItem="{Binding SelectedPreScalarList, Mode=OneWayToSource}" SelectedIndex="0" Height="23" HorizontalAlignment="Center" Margin="0,0,0,0" Name="PCMGenControlCombo" VerticalAlignment="Center" Width="110" /> 
              // Radio Button, Buttons etc are present too                          </Grid></GroupBox></Grid>

PCMGenViewModel:

public ObservableCollection<PCMGenWidgetViewModel> PGenWidgets { get; set; }

    public PCMGenViewModel()
    {
        PGenWidgets = new ObservableCollection<PCMGenWidgetViewModel>();
        PGenWidgets.Add(new PCMGenWidgetViewModel { Description = "PCM Generator 1" });
        PGenWidgets.Add(new PCMGenWidgetViewModel { Description = "PCM Generator 2" });            
    }

PCMGenWidgetViewModel:

private string _description;
    public string Description
    {
        get
        {
            return _description;
        }

        set
        {
            _description = value;
            OnPropertyChanged("Description");
        }
    }

public ObservableCollection<string> PreScalarList
    {
        get { return _PreScalarList; }
        set
        {
            _PreScalarList = value;
            OnPropertyChanged("PreScalarList");
        }
    }

    /// <summary>
    /// Selected Frequency List
    /// </summary>
    private string _selectedPreScalarList;
    public string SelectedPreScalarList
    {
        get { return _selectedPreScalarList; }
        set
        {
            _selectedPreScalarList = value;
            int Listvalue = PreScalarList.IndexOf(_selectedPreScalarList);
            int ListFinalVal = Listvalue + 1;
            SelectedPreScalar(ListFinalVal);
            OnPropertyChanged("SelectedPreScalarList");
        }
    }

    public void SelectedPreScalar(int Select)
    {
        int bitMask;
        bitMask = (0 == 0) ? 0xCF : 0x3F; 
        m_controlRegs[0] &= Convert.ToByte(bitMask);
        m_refClock[0] = Convert.ToByte(18432000 * 2); 
    }

Now this gives me 2 groupboxes on startup :) In my combobox I have A,B,C,D as items. Have a look at the combobox binding at how I am able to retrieve the selected value from the combobox. Here I wanna perform the same operation on all these controls but if different values. Well I mean to say something like this which I did in my C++ app:

for( i = 0;  i < 2; i++) //Constructor: Here 2 is used because we have 2 groupboxes
{
    m_pcmGenPrescalar[i] = new ComboBox(String::empty);
    m_pcmGenPrescalar[i]->addItem(String(T("div 1")), 1);
    m_pcmGenPrescalar[i]->addItem(String(T("div 15")), 2);
    m_pcmGenPrescalar[i]->addItem(String(T("div 255")), 3);
    m_pcmGenPrescalar[i]->addItem(String(T("div 65535")), 4);
    m_pcmGenPrescalar[i]->setEditableText(false);
    m_pcmGenPrescalar[i]->setSelectedId(1, true);
    m_pcmGenPrescalar[i]->addListener(this);
    addAndMakeVisible(m_pcmGenPrescalar[i]);
}

for( i = 0;  i < 2; i++) //Here 2 is used because we have 2 groupboxes
{       
    if(m_pcmGenPrescalar[i] == comboBox) //PreScalar Combobox
    {
        unsigned char bitMask = (0 == i) ? 0xCF : 0x3F; Takes the value of i
        m_controlRegs[0] &= bitMask;
        m_refClock[i] = 18432000 * 2;
    }

If you notice above code, you will find the for loop creating the combobox two times and based on which ever combobox is selected value is taken ini. I.e. if first combobox selection is changed then unsigned char bitMask = (0 == i) ? 0xCF : 0x3F; becomesunsigned char bitMask = (0 == 0) ? 0xCF : 0x3F; if second then,unsigned char bitMask = (0 == 1) ? 0xCF : 0x3F;

This is my query. How can I get to know which combobox I have used. Whether I have usedPCM Gen 1 combo or PCM Gen 2 combo? This is a tricky situation for me. please help :)






ribbon linbreak ?

$
0
0

hi!

I have a ribbon with a alot of Buttons but there are to many Buttons in a line...

I Need all the Buttons in the line!

Here is a Picture with my Problem:

Now I Need an idea that i can see all Buttons (16,27,...)

Is there a linebreak in the ribbon control?

Best Regards

Bernd

WPF trigger on UnsetValue, or how to set MinHeight if Height is not set

$
0
0

Hi,

I have searched for a while but found no solution yet.

What I would like to do:

I want to define a button style where the button has a MinHeight, when the user of the styled button did not set the Height property of that button. If the user sets the Height property in the button (not in the style) the MinHeight from the style should have no effect.

So I need something like that:

<Trigger Property="Height" Value="{x:Static DependenyProperty.UnsetValue}">

 <Setter Property="MinHeight" Value="20"/>

</Trigger>

But I have read somewhere that triggering on UnsetValue does not work. Any ideas or links?

WPF DatagridTextColumn not changing immediately when a DataGridComboBoxColumn’s selection is changed

$
0
0

Hi

I have 2 Tables in a typical Master-Detail relationship :

1) AcctGrps is the Master table. It has 2 columns : AcctGrpCd and AcctGrpName, with AcctGrpCd being the PK.

2) Accts is the Detail table. It has 3 columns : AcctCd, AcctName and AcctGrpCd, with AcctCd being the PK. Thus, each Account has a single AcctGrpCd.

I have a WPF DataGrid in my Window, which displays the Accts data, in the following DataGridColumns :

1) AcctCd  DataGridTextColumn

2) AcctName  DataGridTextColumn

3) AcctGrpCd  DataGridTextColumn

4) AcctGrpName  DataGridComboBoxColumn : This column should be bound such that it displays the AcctGrpName from the AcctGrps table, corresponding to the AcctGrpCd in each Row.

I am retrieving both Tables from the DB, and returning them in DataTable.DefaultView objects, dynamically. (Since the tables are anyway created at runtime, I am not using an ObjectDataProvider.) The DataTable.DefaultView property is of type DataView, which implements the IbindingList interface and therefore provides Change Notifications.

Everything is working perfectly. The only problem is that when I change the selection in the AcctGrpName DataGridComboBoxColumn, the value displayed in the AcctGrpCd DataGridTextColumn changes only when I click on ANOTHER row. I would like the displayed AcctGrpCd to change IMMEDIATELY when the selection is changed in the AcctGrpName DataGridComboBoxColumn. How can I do this ?

The code is shown below :

<Window x:Class="WDataGridAcctsWGrpNames"
   ... ><DockPanel><StackPanel 
           DockPanel.Dock="Top" 
           Orientation="Horizontal"><Button 
                Click="btLoad_Click" 
                Content="Load" Height="23" 
	       Margin="5" 
                Name="btLoad" 
                Width="75" /></StackPanel><DataGrid  
            AutoGenerateColumns="False" 
            DataContext="{Binding}" 
            Height="215" 
            DockPanel.Dock="Top" 
            ItemsSource="{Binding}" 
            Margin="10" 
            Name="dgAccts" 
            Width="407"><DataGrid.Columns><DataGridTextColumn 
                    Header="Acct No" 
                    Binding="{Binding AcctNo}" /><DataGridTextColumn 
                    Header="Acct Name" 
                    Binding="{Binding AcctName}" /><DataGridTextColumn 
                    Header="Acct Grp Cd" 
                    Binding="{Binding AcctGrpCd}" /><DataGridComboBoxColumn 
                    DisplayMemberPath="AcctGrpName" 
                    Header="Acct Group" 
                    ItemsSource="{Binding}" 
                    SelectedValueBinding="{Binding AcctGrpCd}"
                    SelectedValuePath="AcctGrpCd" 
                    x:Name="dgccAcctGrps" /></DataGrid.Columns></DataGrid></DockPanel></Window>
    Private Sub btLoad_Click(
        ByVal sender As System.Object, 
        ByVal e As System.Windows.RoutedEventArgs)
        Try
            ' Disable the Load button.
            btLoad.IsEnabled = False
            ' Display a Wait cursor.
            Me.Cursor = Cursors.Wait
            ' Load Acct Groups data.
            Me.LoadAcctGrps()
            ' Load Accts data.
            Me.LoadAccts()
        Catch ex As Exception
            MessageBox.Show(
              ex.Message,
              ex.GetType.ToString)
        Finally
            ' Enable the Load button.
            btLoad.IsEnabled = True
            ' Display a Default cursor.
            Me.Cursor = Cursors.Arrow
        End Try
    End Sub
    ' Load Acct Groups data.
    Private Sub LoadAcctGrps()…  ' Code to obtain the 
             Acct Groups DataTable …
 
        ' Obtain a reference to the 
          Acct Groups DataTable.
        m_dtAcctGrps = 
              m_dsAcctGrps.Tables(0)
        ' List-Bind the Account Groups 
          DataGridComboBoxColumn to the
	 Account Groups DataTable.
        dgccAcctGrps.ItemsSource = 
               m_dtAcctGrps.DefaultView
    End Sub
    ' Load Accts data.
    Private Sub LoadAccts()
        …  ' Code to obtain the 
             Accts DataTable …
        ' Obtain a reference to the 
          Accts DataTable.
        m_dtAccts = m_dsAccts.Tables(0)
        ' List-bind the Accounts DataGrid to 
          the Accounts DataTable.
        dgAccts.DataContext = 
             m_dtAccts.DefaultView
    End Sub

Please note that DataViews serve as the Binding Source, and they implement the IBindingList interface and therefore already provide Change Notifications.

Perhaps, this problem is being caused because the DataRow’s EndEdit() method is called implicitly, when the user clicks on another Row. I would like to call the EndEdit() method explicitly, but in which event ? The DataGridComboBoxColumn doesn’t provide a SelectionChanged event ! So, in which event can it be called ?

Secondly, does this sort of problem occur if the DataGrid is bound to a List(Of Acct) object and the DataGridComboBoxColumn to a List(Of AcctGrp) object ? I haven’t yet tried this approach and am wondering if this is the standard approach in WPF, rather than binding to a DataView. If so, is it to avoid this kind of a problem ?

Thanks.

Steven


Priting in WPF fails to use the user specified printer tray

$
0
0

Hi,

The following code is being used to print some documents. The problem we are having is that no matter what tray we use it always appears to use the default tray. Any help would be greatly appreciated. We were thinking everything hsould be in the UserPrintTicket:

        /// <summary>Print pages.</summary>
        /// <param name="pageViewModels">The page view models.</param>
        private void PrintPages(IEnumerable<IPageViewModel> pageViewModels)
        {
            var printDialog = new PrintDialog();
            bool? print = printDialog.ShowDialog();
            if (print == true)
            {
                var dw = PrintQueue.CreateXpsDocumentWriter(printDialog.PrintQueue);
                var mediaSize = printDialog.PrintQueue.UserPrintTicket.PageMediaSize;
                printDialog.PrintQueue.CurrentJobSettings.Description = "PDAX Document Pages";
                var area = printDialog.PrintQueue.GetPrintCapabilities().PageImageableArea;
                var img = new Image();
                img.Margin = new Thickness(area.OriginWidth, area.OriginHeight, area.OriginWidth, area.OriginHeight);
                var outputSize = new Size(mediaSize.Width.Value, mediaSize.Height.Value);
                var c = dw.CreateVisualsCollator();
                c.BeginBatchWrite();
                foreach (var page in pageViewModels)
                {
                    img.Source = ConvertByteArrayToBitmap(page.Image);
                    img.Measure(outputSize);
                    img.Arrange(new Rect(outputSize));
                    img.UpdateLayout();
                    c.Write(img);
                }

                c.EndBatchWrite();
            }
        }

SortDirection coming as Null for datagrid

$
0
0

DataGrid sort direction is coming as null. Why is sort direction coming as null during the first click on the column? My intention is to save the sort. But if sort direction itself is coming as null how will I save it?

Please advise

See the sample code below:-

  public partial class MainWindow : Window
    {
        DataTable dt = new DataTable();
        public DataTable MyDataTable
        {
            get { return dt; }
        }

        public MainWindow()
        {
            InitializeComponent();

            DataContext = new List<Person>
            {
                new Person {Name="Tom", Age=10}, 
                new Person {Name="Ken", Age=20}, 
                new Person {Name="Jen", Age=30}, 
            };
        }

        private void testGrid_Sorting(object sender, DataGridSortingEventArgs e)
        {
            if (e.Column.SortDirection == null)
                MessageBox.Show("Sort Direction is Null"); // This is happening during the first click on a column
        }
    }

    public class Person
    {
        public string Name { set; get; }
        public int Age { set; get; }
    }
}

Xaml

 <Grid>
        <DataGrid Name="testGrid"  SelectionMode="Single" ItemsSource="{Binding}" AutoGenerateColumns="True" Width=" 300" Height="300" Sorting="testGrid_Sorting" />
    </Grid>



Viewing all 18858 articles
Browse latest View live


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