2017-03-02 35 views
0

我將此樣式應用於infragistics控件XamDateTimeEditor。 按預期顯示新錯誤圖標。控制錯誤圖標在樣式化後顯示兩次

問題:發生驗證錯誤時,原始錯誤樣式仍顯示。從而使控件具有兩種錯誤圖標樣式。

<Style TargetType="{x:Type XamDateTimeEditor}"> 
    <Setter Property="Validation.ErrorTemplate"> 
     <Setter.Value> 
      <ControlTemplate TargetType="{x:Type Control}"> 
       <DockPanel> 
        <Border 
         Background="Red" 
         Width="25" 
         Height="25" 
         CornerRadius="10" 
         > 
         <TextBlock 
          Text="Error" 
          VerticalAlignment="Center" 
          HorizontalAlignment="Center" 
          FontWeight="Bold" 
          Foreground="White" 
          /> 
        </Border> 
       </DockPanel> 
      </ControlTemplate> 
     </Setter.Value> 
    </Setter> 
</Style> 
+0

嘗試添加以下內容到風格:'' –

+0

@EdPlunkett它完全改變了控件的形狀。現在,我只得到沒有控制權的新供應商。 – John

+0

我很驚訝你有任何控制權,因爲你正在用錯誤模板替換模板。如果在你的setter中你將Property改成'Property =「Validation.ErrorTemplate」',那麼將你的問題中的模板設置爲模板而不是'Template'? –

回答

0

使用實現IDataErrorInfo是最好的方法定製靶向XamDateTimeEditor錯誤模板時,視圖模型。

這是以前討論並展示在我們的論壇:http://www.infragistics.com/community/forums/t/109152.aspx

https://codeblitz.wordpress.com/2009/05/08/wpf-validation-made-easy-with-idataerrorinfo/

+0

歡迎來到Stack Overflow!雖然這可能會在理論上回答這個問題,[這將是更可取的](// meta.stackoverflow.com/q/8259)在這裏包括答案的基本部分,並提供參考鏈接。 –