Change legend Color and Font using the Sillverlight in esri map - silverlight

How to change legend color in code behind in Silverlight:
<esri:Map x:Name="Map" Background="White" Loaded="Map_Loaded" WrapAround="True" Grid.ColumnSpan="3"
MouseClick="Map_MouseClick" >
<esri:ArcGISDynamicMapServiceLayer x:Name="gisdynamic" ID="gisdynamic"
Url="http://192.168.10.1:6080/arcgis/rest/services/babolsar/Babolsar10/MapServer"
DisplayName="نقشه بابلسر" DisableClientCaching="true" Initialized="Map_Initialized" InitializationFailed="layer_InitializationFailed"
DynamicLayerInfos="{x:Null}" ImageFormat="PNG24" LayerDrawingOptions="{x:Null}" ProxyURL="{x:Null}" />
<esri:GraphicsLayer ShowLegend="false" ID="ResultsGraphicsLayer" />
<esri:GraphicsLayer ShowLegend="false" ID="MyGraphicsLayer" />
<esri:GraphicsLayer ShowLegend="false" ID="MySelectionGraphicsLayer" MouseEnter="GraphicsLayer_MouseEnter" MouseLeave="GraphicsLayer_MouseLeave"/>
<esri:GraphicsLayer ShowLegend="false" ID="IdentifyIconGraphicsLayer"/>
<esri:Legend Name="Legend" HorizontalAlignment="Left" Background="White" Foreground="White"
`enter code here` VerticalAlignment="Top" Margin="0,0,0,0" Width="300"
Map="{Binding ElementName=Map}"
LayerItemsMode="Tree" ShowOnlyVisibleLayers="false" Refreshed="Legend_Refreshed">
<esri:Legend.MapLayerTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}" >
</CheckBox>
<Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="100" />
</StackPanel>
</DataTemplate>
</esri:Legend.MapLayerTemplate>
<esri:Legend.LayerTemplate>
<DataTemplate>
<CheckBox Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}" >
</CheckBox>
</DataTemplate>
</esri:Legend.LayerTemplate>
</esri:Legend>

Regarding Legend Color and font changing the following links will help you ..you just visit it
http://support.esri.com/es/knowledgebase/techarticles/detail/38761
https://geonet.esri.com/thread/97018

Related

How to hide field based on condition check in wpf?

I am trying to hide the Textbox inside the list view based on a condition.
<ListView Margin="0" Name="lvAccessPoints" Background="#ff1d1d1d" Grid.Row="1" BorderThickness="0">
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel>
<iconPacks:PackIconModern Kind="ConnectionWifi" Foreground="White" Width="30" Height="30"/>
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="White" Padding="10,0" FontSize="15" VerticalAlignment="Center"/>
<TextBox HorizontalAlignment="Left"
Height="23"
Margin="10,10,0,0"
TextWrapping="Wrap"
Text=""
VerticalAlignment="Top"
Width="120"
TextChanged="TextBox_TextChanged"
Visibility="{Binding Name!=SelectedItem.Name ? Hidden : Visible}"/>
<Button Click="Button_Click_2"></Button>
</WrapPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I am trying like this , and its not seems to be the right way, what i want is when the particular name in the loop matches the selected items name, then only TextBox should show.
What I am doing wrong?
These kind of expressions are not supported in XAML:
Visibility="{Binding Name!=SelectedItem.Name ? Hidden : Visible}"
What you could do is to define a DataTrigger in your DataTemplate that sets the Visibility property of the TextBox to Visible when the parent ListViewItem is selected:
<ListView Margin="0" Name="lvAccessPoints" Background="#ff1d1d1d" Grid.Row="1" BorderThickness="0">
<ListView.ItemTemplate>
<DataTemplate>
<WrapPanel>
<iconPacks:PackIconModern Kind="ConnectionWifi" Foreground="White" Width="30" Height="30"/>
<TextBlock Text="{Binding Name}" FontWeight="Bold" Foreground="White" Padding="10,0" FontSize="15" VerticalAlignment="Center"/>
<TextBox HorizontalAlignment="Left"
x:Name="txt"
Height="23"
Margin="10,10,0,0"
TextWrapping="Wrap"
Text=""
VerticalAlignment="Top"
Width="120"
TextChanged="TextBox_TextChanged"
Visibility="Hidden"/>
<Button Click="Button_Click_2"></Button>
</WrapPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListViewItem}}" Value="True">
<Setter TargetName="txt" Property="Visibility" Value="Visible" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

xceed IntegerUpdown's TabIndex has no effect

I have 4 IntegerUpDowns from the Xceed toolkit. The problem is that the navigation through Tab button does not work at all. I set TabIndex, TabStop properties, but no effect. Maybe somebody had this problem? Any help will be appreciate! Thanks a lot!
Here is a code:
<GroupBox Margin="20"
HorizontalAlignment="Center"
Header="groupbox header text">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0"
Margin="7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text1:" />
<xctk:IntegerUpDown Name="updown1"
Width="50"
Height="25"
Margin="17,0,30,0"
TabIndex="0"
IsTabStop="True"
VerticalAlignment="Center"
Increment="1"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown1_OnValueChanged"
Value="{Binding Property1,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text2" />
<xctk:IntegerUpDown Name="updown2"
Width="50"
Height="25"
Margin="43,0,0,0"
VerticalAlignment="Center"
Increment="2"
TabIndex="2"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property2,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<StackPanel Grid.Row="1"
Margin="7,0,7,7"
Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="text3:" />
<xctk:IntegerUpDown Name="updown3"
Width="50"
Height="25"
Margin="7,0,30,0"
VerticalAlignment="Center"
Increment="1"
TabIndex="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
ValueChanged="Updown3_OnValueChanged"
Value="{Binding Proeprty3,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
<TextBlock VerticalAlignment="Center" Text="text4:"/>
<xctk:IntegerUpDown Name="updown4"
Width="50"
Height="25"
Margin="7,0,0,0"
TabIndex="3"
VerticalAlignment="Center"
Increment="1"
IsTabStop="True"
PreviewKeyDown="NumericUpDown_OnPreviewKeyDown"
Value="{Binding Property4,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</GroupBox>

WPF Element Binding not working in XAML

This should be fairly simple and straightforward but element binding is not working in XAML when using it from resource. It is working fine when using it directly in XAML.
Resources:
<Window.Resources>
<StackPanel x:Key="panel">
<CheckBox x:Name="chkDefaultValue" Content="Default Value"
IsChecked="{Binding ElementName=txtDefaultValue, Path=Text.Length, Mode=OneWay}" />
<TextBox x:Name="txtDefaultValue"
Text="{Binding DefaultValue, Mode=TwoWay, ValidatesOnDataErrors=True}"
IsEnabled="{Binding ElementName=chkDefaultValue, Path=IsChecked}" />
</StackPanel>
</Window.Resources>
XAML:
<StackPanel>
<!-- BINDING NOT WORKING -->
<ContentControl Content="{StaticResource panel}" />
<!-- BINDING WORKING HERE -->
<CheckBox x:Name="chkDefaultValue" Content="Default Value"
IsChecked="{Binding ElementName=txtDefaultValue, Path=Text.Length, Mode=OneWay}" />
<TextBox x:Name="txtDefaultValue"
Text="{Binding DefaultValue, Mode=TwoWay, ValidatesOnDataErrors=True}"
IsEnabled="{Binding ElementName=chkDefaultValue, Path=IsChecked}" />
</StackPanel>
How could i fix it?
You should use DataTemplate
<Window.Resources>
<DataTemplate DataType="{x:Type ContentControl}" x:Key="panel">
<StackPanel>
<CheckBox x:Name="chkDefaultValue" Content="Default Value"
IsChecked="{Binding ElementName=txtDefaultValue, Path=Text.Length, Mode=OneWay}" />
<TextBox x:Name="txtDefaultValue"
Text="{Binding DefaultValue, Mode=TwoWay, ValidatesOnDataErrors=True}"
IsEnabled="{Binding ElementName=chkDefaultValue, Path=IsChecked}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
and
<ContentControl ContentTemplate="{StaticResource panel}" />
didn't check, but probably works
And you can use ControlTemplate
<Window.Resources>
<ControlTemplate x:Key="panel">
<StackPanel>
<CheckBox x:Name="chkDefaultValue"
Content="Default Value"
IsChecked="{Binding ElementName=txtDefaultValue,
Path=Text.Length,
Mode=OneWay}" />
<TextBox x:Name="txtDefaultValue"
IsEnabled="{Binding ElementName=chkDefaultValue,
Path=IsChecked}"
Text="{Binding DefaultValue,
Mode=TwoWay,
ValidatesOnDataErrors=True}" />
</StackPanel>
</ControlTemplate>
</Window.Resources>
and
<ContentControl Template="{StaticResource panel}" />

Nested Stackpanel Button Not working

I have a button nested inside two stack panels as shown by this code.
<StackPanel Grid.Row="1" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
The whole thing is in a Grid in a GroupBox of a UserControl.
The "Max UI Value Met Help" button is not working when clicked. I have similar help buttons to this in a Grid above this StackPanel that work just fine. I tried to copy and paste those in by this and they don't work either.
Why won't this button work?
Update:
I had to switch to a Grid and separate the label & button from the stack of Radio buttons to get it to work, but I want to understand why this didn't work.
The button here is in the same DataContext as the rest of my UserControl. I have multiple help buttons throughout this UserControl and they work, but this one doesn't. It doesn't matter which one I put in there either. I can move the specific button to another location and it works.
I don't like fixing something without understanding why I had to do that.
New Code:
<!--If Max UI is Met-->
<StackPanel Orientation="Horizontal" Grid.Row="1">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<StackPanel Grid.Row="2" DataContext="{StaticResource AutomaticUISettings}">
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
Here is what the code looked like before I went to Grids:
<UserControl x:Class="BogusProgram.DummyUI"
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:autoUIsettings="clr-namespace:BogusProgram.Resources"
xmlns:converters ="clr-namespace:BogusProgram.Converters"
xmlns:views="clr-namespace:BogusProgram.Views"
mc:Ignorable="d" >
<!--UserControl Resources-->
<UserControl.Resources>
<!--Automatic UI Settings-->
<autoUIsettings:AutoUISettings x:Key="AutomaticUISettings" />
<!--Enum to Boolean Converter-->
<converters:EnumBooleanConverter x:Key="enumBooleanConverter" />
</UserControl.Resources>
<!--UserControl Command Bindings-->
<UserControl.CommandBindings>
<!--Compare Change of all settings to Last set-->
<CommandBinding Command="{x:Static views:SetupAutoUI.CompareSettings}" Executed="CommandBinding_Executed"/>
<!--Note: Can use individual RoutedCommands per object-->
<!--http://stackoverflow.com/questions/254992/how-can-i-best-handle-wpf-radio-buttons-->
</UserControl.CommandBindings>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--Enable/Disable Automatic UI-->
<CheckBox Content="Enable Automatic UI" IsChecked="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=AutoUIEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" x:Name="AutoUICheckbox" Margin="10,5" />
<!--Automatic UI Settings-->
<GroupBox Header="Automatic UI Settings" Grid.Row="1" Margin="10,5"
IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=AutoUIEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!--Set Automatic UI change by value-->
<StackPanel Orientation="Horizontal" Margin="10,5">
<Label Content="Change UI By: " />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=ChangUIby, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="CHuiBy"
TextChanged="CHuiBy_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
</StackPanel>
<!--Set when to change UI-->
<StackPanel Orientation="Horizontal" Grid.Row="1" Margin="10,5">
<Label Content="Change UI Every:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=WaitPeriod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="CHuiEv"
TextChanged="CHuiEv_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Change UI Every Help-->
<Button Content="[?]" Command="{Binding ShowCHuiEvHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Change UI for-->
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="10,5" IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}">
<Label Content="Change UI For: " />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriod, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="RunFor"
TextChanged="RunFor_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Change UI For Help-->
<Button Content="[?]" Command="{Binding ShowCHuiForHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Set Max UI value-->
<StackPanel Orientation="Horizontal" Grid.Column="1" Margin="10,5">
<Label Content="Max UI Value:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=MaxUI, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="MaxUI"
TextChanged="MaxUI_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Max UI Value Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Set Min UI value-->
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Margin="10,5">
<Label Content="Min UI Value:" />
<TextBox Text="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=MinUI, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="35" x:Name="MinUI"
TextChanged="MinUI_TextChanged" KeyDown="TextBox_KeyDown" LostFocus="TextBox_LostFocus" />
<!--Min UI Value Help-->
<Button Content="[?]" Command="{Binding ShowMinValueHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Enable/Disable Max Run Period-->
<CheckBox Content="Enable Max Run Period" IsChecked="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" x:Name="RunPeriodCheckbox" Margin="10" Grid.Column="1" Grid.Row="2"/>
</Grid>
<!--If Max UI is Met-->
<StackPanel Grid.Row="1" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Max UI value is met" />
<!--Max UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMaxValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to zero" Margin="10,0" />
<RadioButton GroupName="MeetMaxUI" IsChecked="{Binding Path=Default.MaxMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMin}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Min UI value" Margin="10,0" />
</StackPanel>
<!--If Min UI is Met-->
<StackPanel Grid.Row="2" DataContext="{StaticResource AutomaticUISettings}">
<StackPanel Orientation="Horizontal">
<!--Header-->
<Label Content="If Min UI value is met" />
<!--Min UI Value Met Help-->
<Button Content="[?]" Command="{Binding ShowMinValueMetHelp}" Margin="5" Foreground="DarkCyan" FontSize="10">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
<!--Options-->
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOver}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to 255" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RollOvertoMax}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to Max UI value" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=RolltoValue}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Roll over to calculated Value" Margin="10,0" />
<RadioButton GroupName="MeetMinUI" IsChecked="{Binding Path=Default.MinMetRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=InvertUI}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Change UI in inverse direction" Margin="10,0" />
</StackPanel>
<!--Max Run Period-->
<StackPanel Grid.Row="3" IsEnabled="{Binding Source={x:Static autoUIsettings:AutoUISettings.Default}, Path=RunPeriodEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
DataContext="{StaticResource AutomaticUISettings}">
<!--Header-->
<Label Content="If Run Period is met" />
<!--Options-->
<RadioButton GroupName="MeetRunPeriod" IsChecked="{Binding Path=Default.RunPeriodRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Stop}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Stop" Margin="10,0" />
<RadioButton GroupName="MeetRunPeriod" IsChecked="{Binding Path=Default.RunPeriodRadio, Mode=TwoWay, Converter={StaticResource enumBooleanConverter}, ConverterParameter=Run}"
Command="{x:Static views:SetupAutoUI.CompareSettings}" Content="Continue to running at last UI" Margin="10,0" />
</StackPanel>
</Grid>
</GroupBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Apply" Command="{Binding ApplyAutoUI}" Padding="5" Margin="10,0" IsEnabled="{Binding AutoUIChanged}" />
<Button Content="Close/Cancel" Command="{Binding CloseAutoUI}" Padding="5" Margin="10,0" />
</StackPanel>
</Grid>
actually you have to understand the diffrence between ContentTemplate and ControlTemplate of a Control( here it is Button ).
ContentTemplate says how your control content should look like with keeping all the events ans properties of the control.
ControlTemplate says how your control got overridden means it loose its all properties ans events so you have ti define them separately.means you have change the control actually.i think that you does not want.
so in place of changing ControlTemplate change its ContentTemplate like this.
<Button>
<Button.ContentTemplate>
<DataTemplate>
<contentpresenter/> // place code how your button should look like
</DataTemplate>
</Button.ContentTemplate>
<Button>

Can I use a DataTemplate for toolbar buttons and still make the name meaningful?

I have a Toolbar whose ItemSource is a collection of toolbarItems which contain the bitmap text and other info for the button and the xaml includes a DataTemplate to bind the data to the button.
Our app now needs to become 508 compliant and when I run the Accessible Event Watcher it is listing all the toolbar button names as "Unknown".
Can someone tell me how to provide a meaningful name to the buttons?
Here's the portion of xaml applying to this issue:
<ToolBar.ItemTemplate>
<DataTemplate DataType="{x:Type src:toolBarItem}">
<DataTemplate.Resources>
<src:toolBarItemConverter x:Key="buttonConverter" />
<src:booleanToVisibilityConverter x:Key="boolToVisibilityConverter" />
<src:toolBarButtonFormatConverter x:Key="toolBarFormatDisplayConverter" />
<src:stringToVisibilityConverter x:Key="stringToVisibilityDisplayConverter" />
</DataTemplate.Resources>
<StackPanel Orientation="Horizontal">
<Border Style="{StaticResource SeparatorStyle}" Visibility="{Binding menuSeparator, Converter={StaticResource boolToVisibilityConverter}}"/>
<Button x:Name="listButton" Height="{Binding menuHeight, Mode=OneWay}" Width="{Binding menuWidth}" VerticalAlignment="Top" HorizontalAlignment="Center" Visibility="{Binding isActiveButton, Converter={StaticResource boolToVisibilityConverter}}" Tag="{Binding}"
ToolTip="{Binding menuTooltip}" IsEnabled="{Binding isEnabled}" >
<UniformGrid VerticalAlignment="Center" HorizontalAlignment="Center" Rows="{Binding menuText,Converter={StaticResource toolBarFormatDisplayConverter}}" >
<!-- button image -->
<Image Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{Binding menuImage, Converter={StaticResource buttonConverter}}"/>
<!-- button name -->
<Viewbox StretchDirection="DownOnly" HorizontalAlignment="Center" VerticalAlignment="Bottom" Visibility="{Binding menuText, Converter={StaticResource stringToVisibilityDisplayConverter}}" >
<TextBlock x:Name="buttonName" FontFamily="Segoe UI" Width="{Binding menuWidth}" FontSize="12" Grid.Row="1" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Bottom" Text="{Binding menuText}" Foreground="Black" />
</Viewbox>
</UniformGrid>
<!-- </StackPanel> -->
</Button>
</StackPanel>
</DataTemplate>
</ToolBar.ItemTemplate>
Thanks,
Ron
OK we figured this out. Need to simply bind your names to the AutomationProperties.Name
<Button x:Name="listButton" AutomationProperties.Name="{Binding menuText}"
Height="{Binding menuHeight, Mode=OneWay}" Width="{Binding menuWidth}"
VerticalAlignment="Top" HorizontalAlignment="Center"
Visibility="{Binding isActiveButton,
Converter={StaticResource boolToVisibilityConverter}}"
Tag="{Binding}" ToolTip="{Binding menuTooltip}" IsEnabled="{Binding isEnabled}" >

Resources