I want to change the checkbox text color dynamically in UWP when the checkbox is checked. If I didn't give any color then it should take the default color based on theme. I tried the below code but it does not work.
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
checkBox.Foreground = new SolidColorBrush(Windows.UI.Colors.Red);
}
Can anyone help me on this?
Regards,
Sarath
You can use CheckBox Styles/Template to modify it as per your need.
Refer : https://msdn.microsoft.com/en-us/library/windows/apps/mt299114.aspx
You will need to modify this :
<FontIcon x:Name="CheckGlyph"
FontFamily="{ThemeResource SymbolThemeFontFamily}"
Glyph=""
FontSize="20"
Foreground="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}"
Opacity="0" />
Related
If there are two prism regions defined in a shell, which one is on top is determined by how these are layed out in the shell one below the other.
<Grid Grid.Row="1" x:Name="_redGrid" >
<ContentControl prism:RegionManager.RegionName="RedRegion" />
</Grid>
<Grid Grid.Row="1" x:Name="_greenGrid">
<ContentControl prism:RegionManager.RegionName="GreenRegion" />
</Grid>
For a simple example, you can take a look at this. It has got a red view and a green view.
When you run, it will look like the following.
Is there a way to change this dynamically? Set the zindex of the prism region at run time?
I have extended the above example with a button, objective here is to click the button and change the top to bottom. You can see this example here.
I could do this in the backend file with brute force as follows.
private void btn1_Click(object sender, RoutedEventArgs e)
{
_mainGrid.Children.Remove(_redGrid);
_mainGrid.Children.Remove(_greenGrid);
if (_toggleRegion)
{
_mainGrid.Children.Add(_redGrid);
_mainGrid.Children.Add(_greenGrid);
}
else
{
_mainGrid.Children.Add(_greenGrid);
_mainGrid.Children.Add(_redGrid);
}
_toggleRegion = !_toggleRegion;
}
Click the button, and now the red is on top.
So whats the best way to do this? Is there a feature in Prism which can accomplish this?
I am doing silverlight 4 app.
I have DevExpress GridControl with 4 columns. I have placed HyperlinkButton as display template for one of columns as it shown below. The item source of the gridcontrol has bound in code-behind.
<dxg:GridControl Name="grid" Height="294" Width="634">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Name" />
<dxg:GridColumn FieldName="Id_no" />
<dxg:GridColumn FieldName="Type" />
<dxg:GridColumn Header="View Details">
<dxg:GridColumn.DisplayTemplate>
<ControlTemplate>
<HyperlinkButton Click="HyperlinkButton_Click"/>
</ControlTemplate>
</dxg:GridColumn.DisplayTemplate>
</dxg:GridColumn>
</dxg:GridControl.Columns>
Within the HyperlinkButton's Click eventhandler I want to open a child window and pass details(Name,Id_no,Type) of that particular row to it.
void HyperlinkButton_Click(object sender, RoutedEventArgs e) {
Childwin win_ch = new Childwin();
win_ch.Show();
// pass the row values to the child window???
}
Don't know how get row values of the gridcontrol.
Any ideas? Is there a better method?
You can get row handle of a grid's row that contains the hyperlink via the DataViewBase.GetRowHandleByTreeElement method. Then use the GridControl.GetRow method to obtain the row object.
void HyperlinkButton_Click(object sender, RoutedEventArgs e) {
int rowHandle = tableView3.GetRowHandleByTreeElement((DependencyObject)sender);
object row = gridControl1.GetRow(rowHandle);
// then use the row object
}
Please also review the following help articles:
Obtaining Row Handles
Identifying Rows
In my WPF Window i have RadioButton with default IsChecked property is true.
How to write code for Uncheck the RadioButton.
I tried with Sipmle example.
I take one radiobutton.
<Grid>
<RadioButton Height="16" Margin="54,103,104,0" GroupName="t" Name="radioButton1" VerticalAlignment="Top" IsChecked="True" Unchecked="radioButton1_Unchecked">Text</RadioButton>
</Grid>
private void radioButton1_Unchecked(object sender, RoutedEventArgs e)
{
radioButton1.IsChecked = false;
}
But its not working
Can any one help on this?
Ramki
First of all, it is not possible to uncheck a radiobutton that is singled out. It would make no sense. That's why your event doesn't get fired.
Now, having a single RadioButton will not help you achieve anything: they are meant to be in a group of RadioButtons. Use a CheckBox instead.
Then in the UnChecked event, you don't have to uncheck it: the event is fired because it was unchecked in the first place =)
<Grid>
<CheckBox Height="16" Margin="54,103,104,0" GroupName="t" Name="checkBox1"
VerticalAlignment="Top" IsChecked="True" Unchecked="checkBox1_Unchecked">Text</CheckBox>
</Grid>
private void checkBox1_Unchecked(object sender, RoutedEventArgs e)
{
MessageBox.Show("checkBox1 has been unchecked!");
}
you can't Uncheck a radiobutton if you haven"t another to check !
My application page contains a WebBrowser. I want to add a GestureListener in order to handle the Flick event. But when Flick on the WebBrowser region, it doesn't work. I have tried many ways to let it work, but I failed. I have also tried to use Manipulation instead, but to no effect.
Could someone tell me how to do or whether there is another solution instead?
Following code is the working solution for the Flick or Hold event on the WebBrowser control.
Try the same, it may help you.
Assuming xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" being present in the phone:PhoneApplicationPage tag.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0" Grid.RowSpan="2">
<phone:WebBrowser x:Name="myWebBrowser" Visibility="Visible" IsScriptEnabled="True" IsHitTestVisible="True" Margin="-12,6,0,6" />
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="GestureListener_Flick" Hold="GestureListener_Hold"></toolkit:GestureListener>
</toolkit:GestureService.GestureListener>
</Grid>
And xaml.cs has functions as follows.
private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
MessageBox.Show("Flick");
}
private void GestureListener_Hold(object sender, Microsoft.Phone.Controls.GestureEventArgs e)
{
MessageBox.Show("Hold");
}
I have a xaml with a button like this:
Button.xaml
<Grid x:Name="LayoutRoot" >
<StackPanel >
<Button Content="Button1" Click="Button1_Click" />
</StackPanel >
</Grid>
and Button.xaml.cs:
private void Button1_Click(object sender, RoutedEventArgs e)
{
// Get a instance of ClientOversikt
CustomerView childWindow = m_container.Resolve<CustomerView >();
childWindow.Show();
}
It's working fine. But I want to use Databinding in Button.xaml instead of Click="Button1_Click". How could I do it?
I appreciate all the help
Since you're using Silverlight 4, you can use commands. You bind the Command property of the Button to an instance of ICommand, which will open the child window when executed. Then, when you click on the button, the command will be executed.
This page contains a reasonably good introduction to commanding.