Xaml转C#,如何用C#代码编写 [英] Xaml to C# , how to write in c# code
本文介绍了Xaml转C#,如何用C#代码编写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于某种原因,我想用c#代码编写这些xaml代码.
for some reason I want write those xaml code in c# code.
<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>
我不知道如何编写这些部分:如何将DockPanle添加到ControlTemplate,
DataTrigger的绑定等.......
我在Internet上搜索了信息,但是Xaml代码中的几乎所有内容,c#中的几乎所有内容,都远远不够上述xaml代码.
有人可以给我一个线索吗?
在此先感谢
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
推荐答案
分别针对这些部分中的每一个,在msdn/Internet上浏览一本书或一些文档.
您应该能够找到更多信息.
对于初学者-
控件样式和模板 [ WPF数据绑定-DataTriggers [
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 [^]
XAML并非绝对必要,它只是提供UI层代码和服务器端代码之间的抽象和分离. XAML在客户端计算机上呈现,而C#代码将击中服务器以获取所需的元素.因此,我想XAML可以节省一些服务器行程.
但是,如果您仍然希望编写C#而不是XAML,请查看是否有帮助: ^ ]
DockPanel [
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..
这篇关于Xaml转C#,如何用C#代码编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文