XAML stuff

Post Reply
mute
Posts: 417
Joined: Mon Nov 21, 2011 8:30 pm

XAML stuff

Post by mute »

I've been getting deep into the xaml world and fucking up buzz's ui again... got some new things i want to try after a few years off and update for 2023.

Perhaps Oskari is the only one that can answer this as it should work...

If I try to add or modify the template for the main background grid on machine view, I always get an exception. I can't figure out why... it's clearly a grid... do I need to target a different element instead?

Code: Select all

<Style x:Key="BackgroundGridStyleBase" TargetType="{x:Type Grid}">
    <Setter Property="Background" Value="Red"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Grid}>
                <Grid Background="Blue">
                    <Rectangle Fill="#DAD6C9"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
The different colors are just to see what's working if it worked.

I can do what I want to do using VisualBrush, but you lose all the datacontext since visualbrush is outside the visual and element/logical tree.. so then binding to values (like theme colors) won't work.

e.g.

Code: Select all

   <Style x:Key="BackgroundGridStyleBase" TargetType="{x:Type Grid}">
	<Setter Property="Background" Value="{Binding Path=Buzz.ThemeColors[MV Background]}"/>
    <Setter Property="Background">
      <Setter.Value>
            <VisualBrush Viewport="0.25,0.25,0.5,0.5" >
                    <VisualBrush.Visual>
                        <Grid>
                            <Rectangle Fill="{Binding Path=Buzz.ThemeColors[MV Background]}"/>                        
                            <!--<Rectangle Fill="#DAD6C9"/>                        -->
                            <Image Name="ThemeBG" Source="gfx/themewallpaper.png" Stretch="UniformToFill" Opacity=".0" po:Freeze="True"/>
                            <Canvas>
                                <Grid Canvas.Left="10" Canvas.Top="19" >
                                <TextBlock Name="thing" Text="WHAT" Foreground="Black"  FontWeight="Normal" FontFamily="Veranda" FontSize="40"/>
                                </Grid>
                            </Canvas>
                        </Grid>
                    </VisualBrush.Visual>
            </VisualBrush>
      </Setter.Value>
    </Setter>
  </Style>
either i need to get the controltemplate working (probably easiest) or I need to figure out how to somehow hacks the xamls so that i can pass inherited properties and bindings inside the visual brush.

anyways, only posting here as a last resort.. i've fucked with this basic ass thing for too long and im about to move on to something else.

i also dug through all the machineview/canvas/etc. code to see if there was another spot i could get to the machineview background grid, but didnt really have any luck. maybe there's something with viewGrid / l:machinecanvas, but i can't figure it out.
oskari
Site Admin
Posts: 296
Joined: Mon Nov 21, 2011 2:04 pm

Re: XAML stuff

Post by oskari »

sorry i can't remember any of this stuff. take your time. :)
mute
Posts: 417
Joined: Mon Nov 21, 2011 8:30 pm

Re: XAML stuff

Post by mute »

well that sucks :)

start fuckin around have some fun!
bbzzz.png
bbzzz.png (140.75 KiB) Viewed 1129 times
Post Reply