我有一个DataGrid,它的数据每15秒由后台进程刷新一次.如果任何数据发生变化,我想运行一个动画,突出显示黄色更改值的单元格,然后淡出为白色.我通过以下方式让它工作:
我在Binding.TargetUpdated上创建了一个带有事件触发器的样式
<Style x:Key="ChangedCellStyle" TargetType="DataGridCell">
<Style.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Duration="00:00:15"
Storyboard.TargetProperty=
"(DataGridCell.Background).(SolidColorBrush.Color)"
From="Yellow" To="Transparent" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
Run Code Online (Sandbox Code Playgroud)
然后将其应用于我想要突出显示值的列
<DataGridTextColumn Header="Status"
Binding="{Binding Path=Status, NotifyOnTargetUpdated=True}"
CellStyle="{StaticResource ChangedCellStyle}" />
Run Code Online (Sandbox Code Playgroud)
如果数据库中状态字段的值发生更改,则单元格将以黄色突出显示,就像我想要的那样.但是,有一些问题.
首先,当最初加载数据网格时,整个列以黄色突出显示.这是有道理的,因为所有的值都是第一次加载,因此您可能希望触发TargetUpdated.我确信有一些方法可以阻止这一点,但这是一个相对较小的一点.
真正的问题是如果以任何方式对网格进行排序或过滤,整个列将以黄色突出显示.我想我不明白为什么排序会导致TargetUpdated触发,因为数据没有改变,只是它的显示方式.
所以我的问题是(1)如何在初始加载和排序/过滤时停止这种行为,以及(2)我是否在正确的轨道上,这是一个很好的方法吗?我应该提到这是MVVM.
我正在尝试将MapTileSource的DataSource绑定到我的视图模型上的属性,但是我在Maps上获得了错误REGDB_E_CLASSNOTREG:MapTileSource行(蓝色下划线是VS编辑器).我总是可以使用绑定帮助器来实现相同的效果(我需要在我的应用程序的8.0版本中),但这似乎应该只是...工作.知道什么是错的吗?
<Maps:MapControl Style="{Binding Path=MapStyle}" Center="{Binding Path=MapCenter, Mode=TwoWay}" ZoomLevel="{Binding Path=ZoomLevel, Mode=TwoWay}" MapServiceToken="">
<Maps:MapControl.TileSources>
<Maps:MapTileSource Layer="BackgroundReplacement" DataSource="{Binding Path=BaseLayerDataSource}" />
</Maps:MapControl.TileSources>
</Maps:MapControl>
Run Code Online (Sandbox Code Playgroud)
我也尝试使用具有相同效果的静态数据源:
<Maps:MapControl Style="{Binding Path=MapStyle}" Center="{Binding Path=MapCenter, Mode=TwoWay}" ZoomLevel="{Binding Path=ZoomLevel, Mode=TwoWay}" MapServiceToken="">
<Maps:MapControl.TileSources>
<Maps:MapTileSource Layer="BackgroundReplacement">
<Maps:MapTileSource.DataSource>
<Maps:HttpMapTileDataSource UriFormatString="" />
</Maps:MapTileSource.DataSource>
</Maps:MapTileSource>
</Maps:MapControl.TileSources>
</Maps:MapControl>
Run Code Online (Sandbox Code Playgroud)
编辑:我在http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn632728.aspx上尝试了示例代码,它运行正常,因此很明显MapTileSource本身未注册.但这就是所有代码隐藏,并且不使用数据绑定,因此对我来说没什么用处.
编辑2:如果我忽略错误并尝试将应用程序部署到手机模拟器,我会在视图的InitializeComponent()上得到这个:
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in HikePoint.exe but was not handled in user code
WinRT information: Cannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0] …Run Code Online (Sandbox Code Playgroud) 我一直试图让图像的角落也是圆角但是当我border-radius在div上应用时,图像角落根本不会改变.
#bredband {
height: 330px;
width: 300px;
position: relative;
background-color: #9099A2;
margin: 20px;
float:left;
border-radius:10px;
}Run Code Online (Sandbox Code Playgroud)
<div id="bredband">
<img src="https://upload.wikimedia.org/wikipedia/commons/2/21/Corinex_Router.jpg" width="300" height="200">
<h3>Bredband</h3>
<p>hello world</p>
</div>Run Code Online (Sandbox Code Playgroud)