My styles are leaking

D

DanThMan

I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.

I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?

To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.

Thanks very much for your help,

-Dan
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

What is the XAML that you are using to apply the style? Something tells
me that you are not discriminating too much in how you are applying the
style.
 
D

DanThMan

Dan,

What is the XAML that you are using to apply the style? Something tells
me that you are not discriminating too much in how you are applying the
style.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.
I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?
To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.
Thanks very much for your help,

Hi Nicholas,

Here is my Style definition:


<Style x:Key="DockPanelStyle" TargetType="DockPanel">
<Setter Property="Background" Value="LightSteelBlue" />
<Setter Property="Opacity" Value="0.75" />
<Setter Property="BitmapEffect">
<Setter.Value>
<DropShadowBitmapEffect Color="Black" Direction="315"
ShadowDepth="5" />
</Setter.Value>
</Setter>
</Style>

And here is one of my DockPanels where everything is getting "drop
shadowed":

<DockPanel Style="{StaticResource DockPanelStyle}" Grid.Row="0"
Grid.Column="0" Grid.ColumnSpan="3">
<Label Style="{StaticResource HeadingLabel}"
DockPanel.Dock="Top">Team Map</Label>
<Grid Style="{StaticResource InnerGridStyle}">
<ListView Name="TeamMapListView" ItemsSource="{Binding
Path=DefaultView}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn Header="Contact" CellTemplate="{Binding
Path=ContactName}" />
<GridViewColumn Header="Current Role"
DisplayMemberBinding="{Binding Path=CurrentRole}" />
<GridViewColumn Header="Dominant Role"
DisplayMemberBinding="{Binding Path=DominantRole}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>

Thx,

-Dan
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

I believe it has to do with how you declare your TargetType. I think
you should be doing this:

<Style x:Key="DockPanelStyle" TargetType="{x:Type DockPanel}">

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DanThMan said:
Dan,

What is the XAML that you are using to apply the style? Something
tells
me that you are not discriminating too much in how you are applying the
style.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.
I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?
To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.
Thanks very much for your help,

Hi Nicholas,

Here is my Style definition:


<Style x:Key="DockPanelStyle" TargetType="DockPanel">
<Setter Property="Background" Value="LightSteelBlue" />
<Setter Property="Opacity" Value="0.75" />
<Setter Property="BitmapEffect">
<Setter.Value>
<DropShadowBitmapEffect Color="Black" Direction="315"
ShadowDepth="5" />
</Setter.Value>
</Setter>
</Style>

And here is one of my DockPanels where everything is getting "drop
shadowed":

<DockPanel Style="{StaticResource DockPanelStyle}" Grid.Row="0"
Grid.Column="0" Grid.ColumnSpan="3">
<Label Style="{StaticResource HeadingLabel}"
DockPanel.Dock="Top">Team Map</Label>
<Grid Style="{StaticResource InnerGridStyle}">
<ListView Name="TeamMapListView" ItemsSource="{Binding
Path=DefaultView}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn Header="Contact" CellTemplate="{Binding
Path=ContactName}" />
<GridViewColumn Header="Current Role"
DisplayMemberBinding="{Binding Path=CurrentRole}" />
<GridViewColumn Header="Dominant Role"
DisplayMemberBinding="{Binding Path=DominantRole}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>

Thx,

-Dan
 
N

Nicholas Paldino [.NET/C# MVP]

Dan,

Also, you should specify a TargetType or a Key for the style, not both,
so remove the Key attribute if you want to apply it to all elements of a
particular type, or remove the TargetType attribute if you only want to
apply it to a single, named instance.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

DanThMan said:
Dan,

What is the XAML that you are using to apply the style? Something
tells
me that you are not discriminating too much in how you are applying the
style.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.
I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?
To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.
Thanks very much for your help,

Hi Nicholas,

Here is my Style definition:


<Style x:Key="DockPanelStyle" TargetType="DockPanel">
<Setter Property="Background" Value="LightSteelBlue" />
<Setter Property="Opacity" Value="0.75" />
<Setter Property="BitmapEffect">
<Setter.Value>
<DropShadowBitmapEffect Color="Black" Direction="315"
ShadowDepth="5" />
</Setter.Value>
</Setter>
</Style>

And here is one of my DockPanels where everything is getting "drop
shadowed":

<DockPanel Style="{StaticResource DockPanelStyle}" Grid.Row="0"
Grid.Column="0" Grid.ColumnSpan="3">
<Label Style="{StaticResource HeadingLabel}"
DockPanel.Dock="Top">Team Map</Label>
<Grid Style="{StaticResource InnerGridStyle}">
<ListView Name="TeamMapListView" ItemsSource="{Binding
Path=DefaultView}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn Header="Contact" CellTemplate="{Binding
Path=ContactName}" />
<GridViewColumn Header="Current Role"
DisplayMemberBinding="{Binding Path=CurrentRole}" />
<GridViewColumn Header="Dominant Role"
DisplayMemberBinding="{Binding Path=DominantRole}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>

Thx,

-Dan
 
D

DanThMan

Dan,

I believe it has to do with how you declare your TargetType. I think
you should be doing this:

<Style x:Key="DockPanelStyle" TargetType="{x:Type DockPanel}">

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Dan,
What is the XAML that you are using to apply the style? Something
tells
me that you are not discriminating too much in how you are applying the
style.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.
I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?
To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.
Thanks very much for your help,
-Dan
Hi Nicholas,
Here is my Style definition:
<Style x:Key="DockPanelStyle" TargetType="DockPanel">
<Setter Property="Background" Value="LightSteelBlue" />
<Setter Property="Opacity" Value="0.75" />
<Setter Property="BitmapEffect">
<Setter.Value>
<DropShadowBitmapEffect Color="Black" Direction="315"
ShadowDepth="5" />
</Setter.Value>
</Setter>
</Style>
And here is one of my DockPanels where everything is getting "drop
shadowed":
<DockPanel Style="{StaticResource DockPanelStyle}" Grid.Row="0"
Grid.Column="0" Grid.ColumnSpan="3">
<Label Style="{StaticResource HeadingLabel}"
DockPanel.Dock="Top">Team Map</Label>
<Grid Style="{StaticResource InnerGridStyle}">
<ListView Name="TeamMapListView" ItemsSource="{Binding
Path=DefaultView}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn Header="Contact" CellTemplate="{Binding
Path=ContactName}" />
<GridViewColumn Header="Current Role"
DisplayMemberBinding="{Binding Path=CurrentRole}" />
<GridViewColumn Header="Dominant Role"
DisplayMemberBinding="{Binding Path=DominantRole}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>

-Dan

Thanks, but I get the exact same result if I do this.

-Dan
 
D

DanThMan

Dan,

Also, you should specify a TargetType or a Key for the style, not both,
so remove the Key attribute if you want to apply it to all elements of a
particular type, or remove the TargetType attribute if you only want to
apply it to a single, named instance.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


Dan,
What is the XAML that you are using to apply the style? Something
tells
me that you are not discriminating too much in how you are applying the
style.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.
I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?
To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.
Thanks very much for your help,
-Dan
Hi Nicholas,
Here is my Style definition:
<Style x:Key="DockPanelStyle" TargetType="DockPanel">
<Setter Property="Background" Value="LightSteelBlue" />
<Setter Property="Opacity" Value="0.75" />
<Setter Property="BitmapEffect">
<Setter.Value>
<DropShadowBitmapEffect Color="Black" Direction="315"
ShadowDepth="5" />
</Setter.Value>
</Setter>
</Style>
And here is one of my DockPanels where everything is getting "drop
shadowed":
<DockPanel Style="{StaticResource DockPanelStyle}" Grid.Row="0"
Grid.Column="0" Grid.ColumnSpan="3">
<Label Style="{StaticResource HeadingLabel}"
DockPanel.Dock="Top">Team Map</Label>
<Grid Style="{StaticResource InnerGridStyle}">
<ListView Name="TeamMapListView" ItemsSource="{Binding
Path=DefaultView}">
<ListView.View>
<GridView AllowsColumnReorder="True">
<GridViewColumn Header="Contact" CellTemplate="{Binding
Path=ContactName}" />
<GridViewColumn Header="Current Role"
DisplayMemberBinding="{Binding Path=CurrentRole}" />
<GridViewColumn Header="Dominant Role"
DisplayMemberBinding="{Binding Path=DominantRole}" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</DockPanel>

-Dan

Removing the TargetType generates an error:

Error 2 Value 'Background' cannot be assigned to property 'Property'.
C:\Documents and Settings\Daniel Manes\My Documents\Projects
\Cmd21\Team Map Experiment\Solution\TeamMapExperiment\MainWindow.xaml
24 15 TeamMapExperiment
 
D

DanThMan

I wrote a style in XAML that applies a DropShadowBitmapEffect to some
DockPanels in my Window. This works great. The problem is that, thanks
to property value inheritance, now *everything* inside these
DockPanels has a drop shadow.

I generally like property value inheritance, but I would like to turn
it off in this case. Is that even possible? If not, how do I insert a
"default bitmap effect" or "null bitmap effect" into the styles for
controls lower in the tree?

To reiterate, I want to know how to make a container have a drop
shadow without all the items in the container having a drop shadow.

Thanks very much for your help,

-Dan

I guess it's just a designer issue. I'm not having this problem if I
run it.

-Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top