2014-09-28 23 views
0
     <c1:DataGridTemplateColumn.CellTemplate>       
          <DataTemplate> 
           <CheckBox x:Name="chkBxIsChecked" IsChecked="{Binding IsChecked, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding IsVisible, Mode=TwoWay}" > 
           <Image Name="ErrorImage" Visibility ="{Binding IsImgVisible, Mode=TwoWay}" Source= "../../../Resources/Images/Fail.png" Height="16" Width="16" Margin="5,0,0,0"></Image> 
            <i:Interaction.Triggers> 
             <i:EventTrigger EventName="Checked"> 
              <t:MapEventToCommand Command="{Binding Source={StaticResource TestVM},Path=IsCkCommand}" CommandParameter="checked" /> 
             </i:EventTrigger> 

             <i:EventTrigger EventName="Unchecked"> 
              <t:MapEventToCommand Command="{Binding Source={StaticResource TestVM},Path=IsCkCommand}" CommandParameter="unchecked" /> 
             </i:EventTrigger> 
            </i:Interaction.Triggers> 
           </CheckBox>          
          </DataTemplate>                        
         </c1:DataGridTemplateColumn.CellTemplate>       
        </c1:DataGridTemplateColumn> 

enter image description here
我想隱藏基於從數據庫中的數據列,並顯示圖像的複選框同一列單元格有條件添加圖片和隱藏複選框。 我正在嘗試上述方法,但無法顯示圖像時,我做了可見性.collapse複選框。 我可以做到這一點從代碼隱藏? ,請給我建議。 測試一個記錄在附加圖像我期待顯示圖像,而不是checkbo,因爲它顯示爲空,因爲我使可見性摺疊對行。DataGridTemplateColumn.CellTemplate如何

在此先感謝。

Here is the output i am getting from above code , i am expecting row 3 checkbox column should be displayed an image

回答

1

您已經添加圖片作爲CheckBox的孩子。所以,使父母(複選框)崩潰最終會使孩子(圖片)崩潰。 將checkBox和Image作爲父容器的同級。

更換

<CheckBox> 
    <Image/> 
</CheckBox> 

<Grid> 
    <CheckBox/> 
    <Image/> 
<Grid> 

做工精細假設能見度綁定。

+1

非常感謝它正在工作 – user3125908 2014-09-28 16:47:41

相關問題