Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
for some reason I want write those xaml code in c# code.
HTML
<igdp:xamdatagrid.resources xmlns:igdp="#unknown">
    <Style  x:Key="IconCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
        <setter property="Template">
             <setter.value>
                 <controltemplate targettype="{x:Type igDP:CellValuePresenter}">
                        <dockpanel>
                               <stackpanel>
                                   <grid x:name="CustomerIcon" tooltip="Employee" xmlns:x="#unknown">
                                        <Image  Name="OnlineState_Image"/>
                                              </grid>
                                </stackpanel>
                          </dockpanel>
         <controltemplate.triggers>
           <datatrigger binding="{Binding Path= DataItem.ErrorState}" value="0">
             <setter targetname="CustomerIcon" property="Visibility" value="Visible" />
            </datatrigger>
        </controltemplate.triggers>
        </controltemplate>
     </setter.value>
  </setter>
 </Style>
</igdp:xamdatagrid.resources>



I don't know to how to wrote those parts: how to add DockPanle to ControlTemplate,
DataTrigger's Binding etc.......

I searched Internet for information , but almost everything in Xaml code, very few in in c#, not enough for above xaml code.


could someone give me a clue?
thanks in advance
Posted
Updated 16-Oct-11 22:48pm
v2
Comments
BobJanova 17-Oct-11 6:54am    
I'm not sure it's possible to write control templates except in XAML. Why do you want to, anyway?

Go through a book or some documentation on msdn / the internet for each of these parts individually.
You should be able to find more information.

For starters -
Control Styles and Templates[^]
WPF Data Binding - DataTriggers [^]
 
Share this answer
 
Comments
Alimjan Yasin 17-Oct-11 5:17am    
all of them is xaml code, I still did not find , but thanks!
While XAML is not strictly necessary, it just provides for abstraction and separation between the UI layer code and server side code. XAML is rendered on the client machine while C# code would hit the server to get the required elements. So I would imagine that XAML can be good for saving a few server trips.

However, if you'd still rather write C# instead of XAML, see if this helps: http://stackoverflow.com/questions/6548528/using-c-sharp-instead-of-xaml-in-silverlight[^]

DockPanel[^]

try this link as well, hope this helps

Cheers..
 
Share this answer
 
Comments
Alimjan Yasin 17-Oct-11 5:41am    
thanks , it helped me understand some of part of Xaml to c# rewriting, but I have trouble to how to write below code.
<controltemplate targettype="{x:Type igDP:CellValuePresenter}">
<dockpanel>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900