【XAML】VisualStateManager.VisualStateGroups禁用
现在控件的Template里加入了VisualStateManager.VisualStateGroups,里面包含了大量的动画,有什么方法可以禁用VisualStateManager.VisualStateGroups,或者去掉VisualStateManager.VisualStateGroups里的动画 回复 1楼xinren063的帖子请你提供更详细信息:请问是C1的哪个控件,你需要禁用所有的动画还是哪种动画效果?平台是什么(WPF,Silverlight)? WPF 基本所有控件都有动画 回复 3楼xinren063的帖子
这些是设置在ControlTemplate里的,你需要重写所有控件的ControlTemplate。
打开文件夹C:\Program Files (x86)\ComponentOne\Studio for WPF\C1WPF.4\XAML
可以找到我们所有控件的ControlTemplate 可以简单的给个重写控件ControlTemplate的示例吗,可以以C1FlexGrid为例吗?大量使用了这个控件 回复 5楼xinren063的帖子
1.打开C:\Program Files (x86)\ComponentOne\Studio for WPF\C1WPFFlexGrid.4\XAML
2.打开Generic.xmal文件,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:C1.WPF.FlexGrid">
<!-- brushes -->
<SolidColorBrush x:Key="_RowBackground" Color="#C0E0E0E0" />
<SolidColorBrush x:Key="_AlternatingRowBackground" Color="#00FFFFFF" />
<SolidColorBrush x:Key="_HeaderGridLinesBrush" Color="#E0C8C8C8" />
<SolidColorBrush x:Key="_GridLinesBrush" Color="#FFF0F0F0" />
<SolidColorBrush x:Key="_FrozenLinesBrush" Color="#E0000000" />
<SolidColorBrush x:Key="_GroupRowBackground" Color="#E0E4E4E4" />
<SolidColorBrush x:Key="_CursorBackground" Color="#FFBADDE9" />
<SolidColorBrush x:Key="_SelectionBackground" Color="#A0BADDE9" />
<Color x:Key="_gradFrom">#F0FAFAFA</Color>
<Color x:Key="_gradTo">#F0DBDBDB</Color>
<LinearGradientBrush x:Key="_RowHeaderBackground" EndPoint="1.5,0">
<GradientStop Color="{StaticResource _gradFrom}" Offset="0" />
<GradientStop Color="{StaticResource _gradTo}" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="_ColumnHeaderBackground" EndPoint="0,1">
<GradientStop Color="{StaticResource _gradFrom}" Offset="0" />
<GradientStop Color="{StaticResource _gradTo}" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="_TopLeftCellBackground" EndPoint="1,1">
<GradientStop Color="{StaticResource _gradFrom}" Offset="0" />
<GradientStop Color="{StaticResource _gradTo}" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="_BottomRightCellBackground" EndPoint="1,1">
<GradientStop Color="{StaticResource _gradTo}" Offset="0" />
<GradientStop Color="{StaticResource _gradFrom}" Offset="1" />
</LinearGradientBrush>
<!-- control definition -->
<Style TargetType="local:C1FlexGrid">
<!-- properties -->
<Setter Property="Background" Value="White" />
<Setter Property="RowBackground" Value="{StaticResource _RowBackground}" />
<Setter Property="AlternatingRowBackground" Value="{StaticResource _AlternatingRowBackground}" />
<Setter Property="HeaderGridLinesBrush" Value="{StaticResource _HeaderGridLinesBrush}" />
<Setter Property="GridLinesBrush" Value="{StaticResource _GridLinesBrush}" />
<Setter Property="FrozenLinesBrush" Value="{StaticResource _FrozenLinesBrush}" />
<Setter Property="GroupRowBackground" Value="{StaticResource _GroupRowBackground}" />
<Setter Property="CursorBackground" Value="{StaticResource _CursorBackground}" />
<Setter Property="SelectionBackground" Value="{StaticResource _SelectionBackground}" />
<Setter Property="RowHeaderBackground" Value="{StaticResource _RowHeaderBackground}" />
<Setter Property="ColumnHeaderBackground" Value="{StaticResource _ColumnHeaderBackground}" />
<Setter Property="TopLeftCellBackground" Value="{StaticResource _TopLeftCellBackground}" />
<Setter Property="BottomRightCellBackground" Value="{StaticResource _BottomRightCellBackground}" />
<!-- template -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:C1FlexGrid">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<!--CornerRadius="2">-->
<Grid x:Name="_root">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ScrollBar x:Name="_sbV" Orientation="Vertical" Grid.Column="2" Grid.RowSpan="3" />
<ScrollBar x:Name="_sbH" Orientation="Horizontal" Grid.Row="3" Grid.ColumnSpan="2" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
这段代码有C1FlexGrid的动画效果,包含TopLeftCellBackground等。
3.在你的工程里添加一个Generic.xmal文件,步骤二里的代码就是一个重写的范例。参考步骤二中的代码,改写代码。 C1FlexGrid的模板这么简单,是不是有些资源没写在里面,行的模板、列的模板、单元格的模板等在哪里,或者是怎样的? 回复 7楼xinren063的帖子
我们C1FlexGrid的模板就在上面的代码里面,包含分行分列,如果你需要别的属性或是增加需求,可以自己定义。
还是我理解的不对。 对于这个C1FlexGrid的模板,我认为这边只是最外层的框架,至于里面的行、列、单元格等的模板应该不在这里面,不知道是不是另外有什么地方设置了,或者采用不同的方式加载了 回复 9楼xinren063的帖子
C1的列,行,单元格的模板可以通过代码实现。比如C1FlexGrid.Columns.CellTemplate, 下面的XMAL代码演示如何设置某一列的模板,编辑状态和非编辑状态是不一样的模板。
<c1:C1FlexGrid Name="_flex" ItemsSource="{Binding Products}"
AutoGenerateColumns="False">
<c1:C1FlexGrid.Columns>
<!--
Category column uses a CellEditingTemplate with a ComboBox.
The ComboBox uses an ItemTemplate to show images and text.
The ComboBox has IsSynchronizedWithCurrentItem=false to keep it from
changing the selected item in the single "Categories" collection.
-->
<c1:Column Header="Category" Width="200" >
<c1:Column.CellTemplate>
<DataTemplate>
<Grid Margin="4 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Source="{Binding Category.Picture}" />
<TextBlock Grid.Column="1" Margin="4 0 0 0" VerticalAlignment="Center" Text="{Binding Category.CategoryName}" />
</Grid>
</DataTemplate>
</c1:Column.CellTemplate>
<c1:Column.CellEditingTemplate>
<DataTemplate>
<ComboBox
ItemsSource="{Binding Categories, Source={StaticResource _vm}}"
SelectedValue="{Binding Category}"
IsSynchronizedWithCurrentItem="False" >
<ComboBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="25"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Source="{Binding Picture}" />
<TextBlock Grid.Column="1" Margin="4 0 0 0" VerticalAlignment="Center" Text="{Binding CategoryName}" />
</Grid>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</DataTemplate>
</c1:Column.CellEditingTemplate>
</c1:Column>
<c1:C1FlexGrid.Columns/>
<c1:C1FlexGrid/>
页:
[1]
2