I'm new to C# and wpf so please don't criticize if this is a dumb question.
I have Image and TextBlock inside a DockPanel, then I have a ComboBox which controls where the image would appear around the text. ComboBox items are ("left of text", "right of text", "above the text", "below the text", "center")
I was able to do left, right, top, and bottom by binding DockPanel.Dock but for the center, I need to put the image behind the text (overlaying them) and DockPanel doesn't allow me to do that. I wanted to use Canvas but I was specifically asked not to for a different reason (textwrapping problem, etc.)
Now I just really need to overlay the image and text when "center" is selected from combobox.
xaml
<DockPanel>
<Image Source="{Binding Path=ImageSource, UpdateSourceTrigger=PropertyChanged}" DockPanel.Dock="{Binding Path=ImagePlacementDisplay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock TextWrapping="WrapWithOverflow" Text="{Binding Path=Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
view model
public string SelectedImagePlacement
{
get { return _ex2.ImagePlacement; }
set
{
_ex2.ImagePlacement = value;
OnPropertyChanged("SelectedImagePlacement");
OnPropertyChanged("ImagePlacementDisplay");
}
}
public string ImagePlacementDisplay
{
get
{
switch (SelectedImagePlacement)
{
case "0":
return "Left";
case "1":
return "Right";
case "2":
return "Top";
case "3":
return "Bottom";
case "4":
return "Center"; //not working
default:
return "Right";
}
}
set
{
OnPropertyChanged("ImagePlacementDisplay");
}
}