简体   繁体   中英

Windows Phone 8.1 XAML - Overriding ResourceDictionary entry

I'm using a library ( https://qkit.codeplex.com/ ) to implement a JumpList on my app and I wish to override its default margin for group header elements. This margin is defined on the library code as a resource in a resource dictionary:

<Thickness x:Key="JumpListHeaderItemMargin">19,0,0,9.5</Thickness>

How do I override the value for this key though? I already tried setting it in a resource dictionary directly under the library's JumpList element on my app, but it didn't work:

<q:AlphaJumpList Name="lineJumpList">
    <q:AlphaJumpList.Resources>
        <Thickness x:Key="JumpListHeaderItemMargin">0,0,0,9.5</Thickness>
    </q:AlphaJumpList.Resources>
    ...
</q:AlphaJumpList>

Short answer — you can't.

The authors of the control decided the values aren't part of their public API. If they wanted to, they could expose a DependencyProperty on their control that you can change from the outside.

The simplest workaround — clone the source code of the component, add QKit project into your solution, and change QKit\\Themes\\generic.xaml however you like.

If you don't want to do that, you can copy generic.xaml into eg qkit.xaml in your project, then change JumpListHeaderItemMargin value however you like, then merge qkit.xaml into either app.xaml or into resources on the page where you use that control. This way generic.xaml from the DLL won't be used, because locally-defined style for the control will override what's in the DLL's generic.xaml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM