c# - How to Write a Data Trigger based on Hascode of a Control in WPF -
i'm having property hashcodevalue
. based on hashcode in hashcodevalue property need change visibility of control using datatrigger.
the wpf xaml source code:
<style targettype="{x:type datagridcolumnheader}" x:key="dummyfilterdatagridcolumnheader"> <setter property="template"> <setter.value> <controltemplate targettype="{x:type datagridcolumnheader}"> <button content="super i" visibility="collapsed" /> <button content="super ii" visibility="collapsed" /> <button content="super iii" visibility="collapsed" /> <controltemplate.triggers> <datatrigger property="{binding hashcodevalue}" value="???"> <setter targetname="button" property="visibility" value="visible" /> </datatrigger> </controltemplate.triggers> </controltemplate> </setter.value> </setter> </style>
we can't know hashcode in compile time, generates on run time. out of 3 buttons, property holds 1 of buttons hash code in run time. based on value, want change visibility of corresponding button visible.
kindly assist me how write datatrigger scenario.
since hashcode value known @ runtime, think, should use ivalueconverter reach goal. basic idea have hash converter value, additional string converter parameter, getting bool converter output.
so, code might this:
<controltemplate.triggers> <datatrigger property="{binding hashcodevalue,converter={staticresource myconverter,converterparameter=myparameter}}" value="true"> <setter targetname="button" property="visibility" value="visible" /> </datatrigger> </controltemplate.triggers>
this trick give need, if understood correctly.
Comments
Post a Comment