C# wpf datagrid 动态加载数据后改变单元格颜色bug
代码在这里http://pan.baidu.com/s/1dDGe0lr第一次使用按钮改变颜色没问题,但是滚动轴一拉颜色位置就变了。求教怎么解决。或者有其它动态改变单元格...
代码在这里 http://pan.baidu.com/s/1dDGe0lr
第一次使用按钮改变颜色没问题,但是滚动轴一拉颜色位置就变了。
求教怎么解决。
或者有其它动态改变单元格颜色的方法也行(前提是datagrid数据源是动态的 ,行和列不固定) 展开
第一次使用按钮改变颜色没问题,但是滚动轴一拉颜色位置就变了。
求教怎么解决。
或者有其它动态改变单元格颜色的方法也行(前提是datagrid数据源是动态的 ,行和列不固定) 展开
展开全部
解决方案来源于:http://social.msdn.microsoft.com/Forums/zh-CN/4d16fa21-7a07-4564-a3ba-3ff651b09b73/wpf-?forum=wpfzhchs
MainWindow.xaml 文件中的的DataGrid 加入 VirtualizingStackPanel.IsVirtualizing="False" 属性 如下面内容:
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="512,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<DataGrid VirtualizingStackPanel.IsVirtualizing="False" AutoGenerateColumns="False" CanUserAddRows="False" Margin="12,54,81,0" Name="dg_JieGuo" BeginningEdit="dg_JieGuo_BeginningEdit" VerticalScrollBarVisibility="Auto" IsStylusDirectlyOverChanged="dg_JieGuo_IsStylusDirectlyOverChanged" />
<Label Content="表格行数" Height="25" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label49" VerticalAlignment="Top" Width="58" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="74,12,0,0" Name="textBox3" Text="50" VerticalAlignment="Top" Width="37" />
<Label Content="改变单元格颜色" Height="25" HorizontalAlignment="Left" Margin="148,10,0,0" Name="label1" VerticalAlignment="Top" Width="94" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="271,12,0,0" Name="textBox1" Text="1" VerticalAlignment="Top" Width="37" />
<Label Content="列" Height="25" HorizontalAlignment="Left" Margin="314,12,0,0" Name="label2" VerticalAlignment="Top" Width="27" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="341,12,0,0" Name="textBox2" Text="1" VerticalAlignment="Top" Width="37" />
<Label Content="行" Height="25" HorizontalAlignment="Left" Margin="244,10,0,0" Name="label3" VerticalAlignment="Top" Width="24" />
</Grid>
google 方法就搜 “wpf datagridview scrollbar 滑动事件”
MainWindow.xaml 文件中的的DataGrid 加入 VirtualizingStackPanel.IsVirtualizing="False" 属性 如下面内容:
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="512,12,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />
<DataGrid VirtualizingStackPanel.IsVirtualizing="False" AutoGenerateColumns="False" CanUserAddRows="False" Margin="12,54,81,0" Name="dg_JieGuo" BeginningEdit="dg_JieGuo_BeginningEdit" VerticalScrollBarVisibility="Auto" IsStylusDirectlyOverChanged="dg_JieGuo_IsStylusDirectlyOverChanged" />
<Label Content="表格行数" Height="25" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label49" VerticalAlignment="Top" Width="58" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="74,12,0,0" Name="textBox3" Text="50" VerticalAlignment="Top" Width="37" />
<Label Content="改变单元格颜色" Height="25" HorizontalAlignment="Left" Margin="148,10,0,0" Name="label1" VerticalAlignment="Top" Width="94" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="271,12,0,0" Name="textBox1" Text="1" VerticalAlignment="Top" Width="37" />
<Label Content="列" Height="25" HorizontalAlignment="Left" Margin="314,12,0,0" Name="label2" VerticalAlignment="Top" Width="27" />
<TextBox Height="21" HorizontalAlignment="Left" Margin="341,12,0,0" Name="textBox2" Text="1" VerticalAlignment="Top" Width="37" />
<Label Content="行" Height="25" HorizontalAlignment="Left" Margin="244,10,0,0" Name="label3" VerticalAlignment="Top" Width="24" />
</Grid>
google 方法就搜 “wpf datagridview scrollbar 滑动事件”
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询