c# - Unable to Style TabControl -
within application, have tried jazz in terms of appearance have tried using mahapps.metro. i've hit little of snag.
within application, have tabcontrol , have used style following ;
<page.resources> <resourcedictionary> <resourcedictionary.mergeddictionaries> <!--resource dictionary mahapps. --> </resourcedictionary.mergeddictionaries> <style targettype="{x:type tabitem}"> <setter property="headertemplate"> <setter.value> <datatemplate> <stackpanel orientation="horizontal"> <!-- formname name of viewmodel--> <textblock text="{binding formname}" verticalalignment="center" margin="2" /> </stackpanel> <datatemplate.triggers> <datatrigger binding="{binding isvalid}" value="false"> </datatrigger> </datatemplate.triggers> </datatemplate> </setter.value> </setter> </style> </resourcedictionary> </page.resources> <!-- itemsource bound observablecollection of forms used validate progress bar, uses viewmodels--> <tabcontrol x:name="tabcontrol" grid.row="1" itemssource="{binding forms}" selectedindex="0" borderbrush="black" /> obviously, isn't using mahapps.metro tabcontrol. however, within style of tabcontrol changed targettype following causes within page increase size , combines 2 tab contents one;
<style targettype="{x:type controls:metrotabitem}" basedon="{staticresource metrotabitem}"> 
any grateful in regards helping me implement mahapps.meto tab control , clearing doing wrong. cheers.
the reason you're getting mixed result because metrotabitem doesn't have template of own think , uses tabitem style override instead. original approach on right path.
i can't tell how actual style configured (the cut paste of resourcedictionary you've pasted here won't compile is) if use block of resources (and add yours), should work. tested , working here.
<resourcedictionary> <resourcedictionary.mergeddictionaries> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/colours.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/fonts.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/controls.animatedsinglerowtabcontrol.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/blue.xaml" /> <resourcedictionary source="pack://application:,,,/mahapps.metro;component/styles/accents/baselight.xaml" /> <resourcedictionary> <style targettype="{x:type tabitem}" basedon="{staticresource {x:type tabitem}}"> <setter property="headertemplate"> <setter.value> <datatemplate > <stackpanel orientation="horizontal"> <textblock text="{binding formname}" verticalalignment="center" margin="2" /> </stackpanel> <datatemplate.triggers> <datatrigger binding="{binding isvalid}" value="false" /> </datatemplate.triggers> </datatemplate> </setter.value> </setter> </style> </resourcedictionary> </resourcedictionary.mergeddictionaries> </resourcedictionary> note: vs complain "a loop detected in property expressions." sort of true works fine. can ignore error. solution build , run fine.
Comments
Post a Comment