可以配置(只读)DataGrID,以便用户只能选择或专注于整个行,而不是单个字段.
如果不可能,是否只有第一个元素可选择的优雅方法 – 例如在标准的Windows打开对话框中,如果您更改为“详细信息”视图,则每行都有几列(文件名,创建日期,大小等) ),但您只能突出显示文件名列中的项目.
解决方法 这是我的(跛脚)版本,在当前行的所选行和灰色背景上添加一个黑色背景.我必须覆盖样式,因为我单独绘制单元格,并且所选择的行被隐藏.只需将粘贴的代码添加到DataGrID实例中即可:
<local:DataGrID.RowStyle> <Style targettype="local:DataGrIDRow"> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate targettype="local:DataGrIDRow"> <localprimitives:DataGrIDFroZenGrID name="Root"> <vsm:visualstatemanager.VisualStateGroups> <vsm:VisualStateGroup x:name="CommonStates"> <vsm:VisualStateGroup.Transitions> <vsm:VisualTransition GeneratedDuration="0" /> </vsm:VisualStateGroup.Transitions> <vsm:VisualState x:name="normal" /> <vsm:VisualState x:name="normal AlternatingRow"> <Storyboard> <DoubleAnimation Storyboard.Targetname="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To="0"/> </Storyboard> </vsm:VisualState> <vsm:VisualState x:name="MouSEOver"> <Storyboard> <DoubleAnimation Storyboard.Targetname="BackgroundRectangle" Storyboard.TargetProperty="Opacity" Duration="0" To=".5"/> </Storyboard> </vsm:VisualState> <vsm:VisualState x:name="normal Selected"> <Storyboard> <DoubleAnimation Storyboard.Targetname="BackgroundRectangleSelected" Storyboard.TargetProperty="Opacity" Duration="0" To="1" /> </Storyboard> </vsm:VisualState> <vsm:VisualState x:name="MouSEOver Selected"> <Storyboard> <DoubleAnimation Storyboard.Targetname="BackgroundRectangleSelected" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> </Storyboard> </vsm:VisualState> <vsm:VisualState x:name="Unfocused Selected"> <Storyboard> <DoubleAnimation Storyboard.Targetname="BackgroundRectangleSelected" Storyboard.TargetProperty="Opacity" Duration="0" To="1"/> <colorAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.Targetname="BackgroundRectangleSelected" Storyboard.TargetProperty="(Shape.Fill).(SolIDcolorBrush.color)"> <SplinecolorKeyFrame KeyTime="0" Value="Black"/> </colorAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> </vsm:visualstatemanager.VisualStateGroups> <GrID.RowDeFinitions> <RowDeFinition Height="*"/> <RowDeFinition Height="auto"/> <RowDeFinition Height="auto"/> </GrID.RowDeFinitions> <GrID.ColumnDeFinitions> <ColumnDeFinition WIDth="auto" /> <ColumnDeFinition WIDth="*" /> </GrID.ColumnDeFinitions> <GrID.Resources> <Storyboard x:Key="DetailsVisibleTransition"> <DoubleAnimation Storyboard.Targetname="DetailsPresenter" Storyboard.TargetProperty="ContentHeight" Duration="00:00:0.1" /> </Storyboard> </GrID.Resources> <Rectangle x:name="BackgroundRectangle" GrID.rowspan="2" GrID.ColumnSpan="2" Opacity="0" Fill="#FFBADDE9"/> <Rectangle x:name="BackgroundRectangleSelected" GrID.rowspan="2" GrID.ColumnSpan="2" Opacity="0" Fill="Black"/> <localprimitives:DataGrIDRowheader GrID.rowspan="3" name="Rowheader" localprimitives:DataGrIDFroZenGrID.IsFroZen="True" /> <localprimitives:DataGrIDCellsPresenter margin="2" GrID.Column="1" name="CellsPresenter" localprimitives:DataGrIDFroZenGrID.IsFroZen="True" /> <localprimitives:DataGrIDDetailsPresenter GrID.Row="1" GrID.Column="1" name="DetailsPresenter" /> <Rectangle GrID.Row="2" GrID.Column="1" name="BottomGrIDline" HorizontalAlignment="Stretch" Height="1" /> </localprimitives:DataGrIDFroZenGrID> </ControlTemplate> </Setter.Value> </Setter> </Style> </local:DataGrID.RowStyle>总结
以上是内存溢出为你收集整理的仅在Silverlight DataGrid中突出显示整行全部内容,希望文章能够帮你解决仅在Silverlight DataGrid中突出显示整行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)