我为定位按钮的超链接做了一个简单的样式:
<Style x:Key="Hyperlink" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{StaticResource ForegroundDarkBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<TextBlock x:Name="innerText" Text="{TemplateBinding Content}" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{StaticResource AppDarkBlueBrush}" />
<Setter TargetName="innerText" Property="TextDecorations" Value="Underline" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我的问题是,当应用于设置了FontSize
,FontWeight
,FontFamily
之类的某些属性的按钮控件时,它们将被忽略并且不起作用:
<Button
Command="{Binding OpenCommand}"
Content="Open"
FontSize="20"
Style="{StaticResource Hyperlink}" />
如何在样式模板中使TextBlock
继承此类属性?
忘记了我提到的FontSize
之类的属性实际上可以工作,但仅在设计模式下有效。
答案 0 :(得分:1)
您可以指示您希望文本块从“按钮”“继承”某些属性,如下所示:
def saveResults(a,b):
preds_test = a.predict(b, verbose=1)
cutoff=0.5
a = 'C:/Users/ultim\Desktop/Rest/testpredict'
for i in range(len(preds_test)):
lab_img = label(preds_test[i] > cutoff)
for i in range(1, lab_img.max() + 1):
lab_img[i] = np.array(lab_img[i], dtype=np.uint8)
cv2.imwrite('a' + i, lab_img[i])
saveResults(modelZ,X_test)