Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 重新序列化只是wpf控件的一部分。可能吗?_.net_Wpf_Wpf Controls_Styles_Controltemplate - Fatal编程技术网

.net 重新序列化只是wpf控件的一部分。可能吗?

.net 重新序列化只是wpf控件的一部分。可能吗?,.net,wpf,wpf-controls,styles,controltemplate,.net,Wpf,Wpf Controls,Styles,Controltemplate,我只想重新设计WPF控件的一部分 (具体来说,我想将滚动条上的滚动按钮放大) 现在我可以做到了,没问题。我提取了默认样式。进行了必要的调整,并将修改后的样式包含在我的应用程序中 问题是我必须在替换样式中包含整个控件模板,而我要更改的只是2个值 <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate TargetType="ScrollBar">

我只想重新设计WPF控件的一部分

(具体来说,我想将滚动条上的滚动按钮放大)

现在我可以做到了,没问题。我提取了默认样式。进行了必要的调整,并将修改后的样式包含在我的应用程序中

问题是我必须在替换样式中包含整个控件模板,而我要更改的只是2个值

  <Setter Property="Control.Template">
    <Setter.Value>
      <ControlTemplate TargetType="ScrollBar">
        <Grid Background="{TemplateBinding Panel.Background}" SnapsToDevicePixels="True">
          <Grid.ColumnDefinitions>
            <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
            <ColumnDefinition Width="1E-05*" />
            <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}" />
          </... etc


在这种情况下,您应该能够,因为模板伸出手并从资源中获取值:

<ScrollBar xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <ScrollBar.Resources>
        <sys:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}">50</sys:Double>
    </ScrollBar.Resources>
</ScrollBar>

50

如果模板对值进行了硬编码,你就倒霉了。

很酷的提示,它可能对我也很有用:)