Disable focus on readonly columns

4 posts, 1 answers
  1. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 01 Jun 2015 Link to this post

    Hi,

    regarding to the post "http://www.telerik.com/forums/avoid-focus-on-radgridviewcolumn"

    is there a possibility to disable the focus on a read only grid column? The property "Focusable" has no effect.

  2. Answer
    Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 02 Jun 2015 Link to this post

    Hi Simon ,

    As there is no built-in functionality to achieve this, a possible approach would be to use the IsEnabled property of GridViewCell. For this purpose, you will need to define a Style and apply it through the CellStyle property of GridViewDataColumn:
    <Style x:Key="disabledCellStyle" TargetType="telerik:GridViewCell">
        <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
    </Style>

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" IsReadOnly="True"
             CellStyle="{StaticResource disabledCellStyle}"/>

    Hope this helps.

    Regards,
    Stefan X1
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Bharat
    Bharat avatar
    3 posts
    Member since:
    Jul 2015

    Posted 15 Sep 2015 in reply to Stefan X1 Link to this post

    How Can we achieve this in c# code, i am not creating the columns from xaml..
  5. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 16 Sep 2015 Link to this post

    Hi Bharat,

    The Style can be defined in XAML and then set programmatically through the CellStyle property of a given column. You can take a look at the code snippet below.
    GridViewDataColumn col = new GridViewDataColumn()
    {
        CellStyle = this.Resources["disabledCellStyle"] as Style
    };

    Regards,
    Stefan X1
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top