Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai
I created a user control called IGrid ,I changed back color , AutoGenerateColumns="False" etc. and compiled to dll.
But when i add this control to a wpf form I am not getting the seting in new control.I get default color and AutoGenerateColumns becomes to true
I use this code

Xaml

HTML
<DataGrid  x:Class="IGrid"
             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:MyGrid"
             mc:Ignorable="d" Height="200" Width="400" AutoGenerateColumns="False">
    <DataGrid.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF787575" Offset="1"/>
            <GradientStop Color="White"/>
        </LinearGradientBrush>
    </DataGrid.Background>
</DataGrid>



Please help me what is the problem.
thanks.
Posted
Updated 14-Jan-16 23:02pm
v2

Hi, Try to set Background and AutoGenerateColumns in code behind, like,
C#
public partial class IGrid : DataGrid
{
   public IGrid()
   {
      InitializeComponent();
      this.AutoGenerateColumns = true;
      this.Background = new SolidColorBrush(Colors.LightBlue);
   }
}

Create UserControl Library and define your custom user controls there.
 
Share this answer
 
hai

Thanks for reply.
I tried this also but not working.
I created new UserControl Library wrote AutoGenerateColumns="False" in code,compiled to dll file. In new project i added this in ToolBox , when i drag this control on a wpf form I get AutoGenerateColumns="True" , color to default etc. I have to change again all properties. Please give a solution

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900