Infolink

 

Search This Blog

Nov 9, 2012

Create an override for a datagrid within a user control(WPF)

The XAML

<UserControl>
 <Grid>
        <toolkit:DataGrid  ItemsSource="{Binding Source={StaticResource DocumentsVS}}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False"
                FontSize="16" Name="_dgDocuments" Style="{StaticResource EklektosDataGridStyle}" . . . >
</UserControl>

OR

<local:MyDataGrid x:Name="dataGrid"/>

In case you want to override the OnCreateAutomationPeer of your dataGrid, you have to subclass the dataGrid -

public class MyDataGrid : DataGrid
{
    protected override AutomationPeer OnCreateAutomationPeer()
    {
        return null;
    }
}

And in constructor of your UserControl -

public CDocumentChecklistView()
{
    InitializeComponent();
    AutomationPeer a = UIElementAutomationPeer.CreatePeerForElement(dataGrid);
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...