(vs express2012, wpf, .net4.5) new c# development. developing windows app using kinect sdk 1.7
i want style kinecttilebutton @ runtime not sure how, have tried various solutions found on stack none have worked, assuming due lack of c# knowledge, please provide answers dummies.
the xaml markup is:
<k:kinecttilebutton background="{x:null}" borderthickness="3" height="auto" margin="50,0" borderbrush="#ff181919" width="auto" />
the problem ktb's created dynamically @ runtime. in code behind:
for (var index = 0; index < 300; ++index) { var button = new kinecttilebutton (); this.width = double.nan; image img = new image(); if (files[fileindex].fullname.endswith(".jpg")) img.source = new bitmapimage(new uri(files[fileindex].fullname)); button.content = img; this.wrappanel.children.add(button); fileindex++; if (fileindex >= files.length) fileindex = 0; }
i amended code, maybe might developing ms kinect arent great @ c#.
after little tinkering , how styled ktb
var button = new kinecttilebutton (); button.background = null; button.margin = new thickness(40); button.height = double.nan; button.width = double.nan; button.borderbrush = brushes.transparent;
i'm not sure you're creating kinecttilebuttons
i'll work under assumption you're doing in codebehind of 1 of outer controls(window
). can create style in xaml
, use findresource(...)
assign in codebehind. if way, you'll able reuse style multiple buttons.
xaml:
<window> ... <window.resources> <style x:key="kinectbuttonstyle" targettype=k:kinecttilebutton> <setter property="margin" value="40"> <setter property="borderbrush" value="transparent" /> ... </style> </window.resources> </window>
codebehind:
var button = new kinecttilebutton { style = findresource("kinectbuttonstyle") style }
in fact, if remove key
style
, applied implicitly , wouldn't need findresource(...)
lookup. don't know whether that's desirable or not you.
Comments
Post a Comment