As one with very little to no clue at WPF....
I am trying to switch user controls. currently my code is using "new" to get the user control object but it is very problematic cause this code is being read lot of times and the objects are not released ,I am using very weak hardware.
Is there any other way to switch between user controls?
I have xaml file thats look like that
<UserControl x:Uid="UserControl_1" x:Class="ddd.WindowFooter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ddd"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:Core="clr-namespace:Microsoft.Expression.Interactivity.Core"
xmlns:ddd="clr-namespace:ddd"
xmlns:Core1="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
DataContext="{Binding Source={StaticResource _indicatorSelector}}" KeyboardNavigation.TabNavigation="None">
<Border x:Uid="Border_1" HorizontalAlignment="Left" VerticalAlignment="Bottom" CornerRadius="0,10,0,0" Background="{Binding Background}">
<StackPanel x:Uid="StackPanel_1" Margin="10,10,10,0">
<Grid x:Uid="Grid_1">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Uid="ColumnDefinition_1" />
<ColumnDefinition x:Uid="ColumnDefinition_2" />
</Grid.ColumnDefinitions>
<ContentControl x:Uid="contentControl1" Content="{Binding Slot1Control}" MouseDown="DoMouseDown"
Height="40" Name="contentControl1" Width="100" Grid.Column="0" />
<ContentControl x:Uid="contentControl2" Content="{Binding Slot2Control}" MouseLeftButtonUp="DoMouseDown"
</Grid>
<Grid x:Uid="Grid_2" Grid.Row="1" Width="200" Height="22" Margin="0,7" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<Viewbox x:Uid="Viewbox_1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Uniform">
<ContentControl x:Uid="ContentControl_1" HorizontalAlignment="Left" VerticalAlignment="Top" ContentTemplate="{StaticResource SomeImage}" />
</Viewbox>
</Grid>
</StackPanel>
</Border>
</UserControl>
And CS thats looks like
public class IndicatorSelector : INotifyPropertyChanged
{
UserControl Slot1Control{
get
{
return new Slot1UserControl();
}
}
UserControl Slot2Control{
get
{
return new Slot2UserControl();
}
}
}
Thanks