noesis_user
Topic Author
Posts: 14
Joined: 08 May 2014, 00:04

Styling buttons from codebehind

08 May 2014, 00:13

I am trying to apply style to a radio button from code behind. The style is defind in xaml as follows,
<Style x:Key="RadioButtonStyle2" TargetType="{x:Type RadioButton}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type RadioButton}">
                <Grid>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Codebehind is :
Noesis::Gui::RadioButton* plugin_button = new Noesis::Gui::RadioButton();

Ptr<IResourceKey> key = ResourceKeyString::Create("RadioButtonStyle2");
Noesis::Gui::Style* style = main_root->FindResource<Noesis::Gui::Style>(key.GetPtr());
plugin_button->SetStyle(s);
It gives me weird linking errors although I am not missing anything as such. Can you please suggest?
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Styling buttons from codebehind

08 May 2014, 11:52

Could you please attach the link warnings you are getting?

Under which platform are you building your project?

P.S. Just an advice, in your C++ code you can use Ptr smart pointer to take care of object references. You have to write: "Ptr<Noesis::Gui::RadioButton> plugin_button = *new Noesis::Gui::RadioButton();". Then you don't need to delete this object manually, it will be deleted automatically when no references to the object are kept.

Who is online

Users browsing this forum: No registered users and 3 guests